diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-10-25 00:00:53 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-10-25 00:00:53 +0000 |
commit | 53aec2a2770afc242c70fd88975cd0ea389087c0 (patch) | |
tree | 89c8c70abe8d206e6134f451ee2200c593d0fc63 | |
parent | e925322569cb4aad26cc62036a13e2d3daed862d (diff) |
'constexpr' and 'friend' are both declaration specifiers. Teach the parser this, for better error recovery.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166645 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 8 | ||||
-rw-r--r-- | test/Parser/recovery.cpp | 5 |
2 files changed, 9 insertions, 4 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 26175a50f5..bb5f333749 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -3771,6 +3771,9 @@ bool Parser::isDeclarationSpecifier(bool DisambiguatingWithExpression) { case tok::kw_virtual: case tok::kw_explicit: + // friend keyword. + case tok::kw_friend: + // static_assert-declaration case tok::kw__Static_assert: @@ -3779,11 +3782,10 @@ bool Parser::isDeclarationSpecifier(bool DisambiguatingWithExpression) { // GNU attributes. case tok::kw___attribute: - return true; - // C++0x decltype. + // C++11 decltype and constexpr. case tok::annot_decltype: - return true; + case tok::kw_constexpr: // C11 _Atomic() case tok::kw__Atomic: diff --git a/test/Parser/recovery.cpp b/test/Parser/recovery.cpp index ff687583c2..784002d536 100644 --- a/test/Parser/recovery.cpp +++ b/test/Parser/recovery.cpp @@ -23,12 +23,15 @@ void g() { struct S { int a, b, c; S(); + int x // expected-error {{expected ';'}} + friend void f() }; 8S::S() : a{ 5 }, b{ 6 }, c{ 2 } { // expected-error {{unqualified-id}} return; } int k; -int l = k; +int l = k // expected-error {{expected ';'}} +constexpr int foo(); 5int m = { l }, n = m; // expected-error {{unqualified-id}} |