summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-10-25 00:00:53 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-10-25 00:00:53 +0000
commitd16fe12e77169ba2f791f7cec0e2d54dab7690d9 (patch)
tree8d0d4ffa76fa534967e95af092fa270f74d0ae9e
parent527b15e8f17d8b200b95bcc843d4d717d6848c67 (diff)
downloadbcm5719-llvm-d16fe12e77169ba2f791f7cec0e2d54dab7690d9.tar.gz
bcm5719-llvm-d16fe12e77169ba2f791f7cec0e2d54dab7690d9.zip
'constexpr' and 'friend' are both declaration specifiers. Teach the parser this, for better error recovery.
llvm-svn: 166645
-rw-r--r--clang/lib/Parse/ParseDecl.cpp8
-rw-r--r--clang/test/Parser/recovery.cpp5
2 files changed, 9 insertions, 4 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 26175a50f53..bb5f3337499 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/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/clang/test/Parser/recovery.cpp b/clang/test/Parser/recovery.cpp
index ff687583c25..784002d5367 100644
--- a/clang/test/Parser/recovery.cpp
+++ b/clang/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}}
OpenPOWER on IntegriCloud