diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index a1e3a0c51d8e1..14e5da60aef81 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -450,6 +450,7 @@ Bug Fixes to AST Handling legal representation. This is fixed because ElaboratedTypes don't exist anymore. (#GH43179) (#GH68670) (#GH92757) - Fix unrecognized html tag causing undesirable comment lexing (#GH152944) - Fix comment lexing of special command names (#GH152943) +- Use `extern` as a hint to continue parsing when recovering from a malformed declaration. Miscellaneous Bug Fixes ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 22c01c4e371f3..d6cd7eb8c2c3d 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -2083,6 +2083,9 @@ void Parser::SkipMalformedDecl() { return; break; + case tok::kw_extern: + // 'extern' at the start of a line is almost certainly a good + // place to pick back up parsing case tok::kw_namespace: // 'namespace' at the start of a line is almost certainly a good // place to pick back up parsing, except in an Objective-C diff --git a/clang/test/Parser/recovery-after-expected-unqualified-id.cpp b/clang/test/Parser/recovery-after-expected-unqualified-id.cpp new file mode 100644 index 0000000000000..8019b46df1e7b --- /dev/null +++ b/clang/test/Parser/recovery-after-expected-unqualified-id.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -verify %s + +3.2 // expected-error {{expected unqualified-id}} + +extern "C" { + typedef int Int; +} + +Int foo(); // Ok