]> granicus.if.org Git - clang/commitdiff
Improve recovery from ill-formed scope specifiers. Fixes PR3670.
authorDouglas Gregor <dgregor@apple.com>
Fri, 6 Mar 2009 19:06:37 +0000 (19:06 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 6 Mar 2009 19:06:37 +0000 (19:06 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66286 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/SemaCXX/nested-name-spec.cpp

index f4c2788217d7fd3ac0a50d78e93ebf130064c3ba..b25ba431496efcb592de22ad85cc369b83bd35d2 100644 (file)
@@ -1209,7 +1209,11 @@ Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl,
   }
 
   // See if this is a redefinition of a variable in the same scope.
-  if (!D.getCXXScopeSpec().isSet() && !D.getCXXScopeSpec().isInvalid()) {
+  if (D.getCXXScopeSpec().isInvalid()) {
+    DC = CurContext;
+    PrevDecl = 0;
+    InvalidDecl = true;
+  } else if (!D.getCXXScopeSpec().isSet()) {
     LookupNameKind NameKind = LookupOrdinaryName;
 
     // If the declaration we're planning to build will be a function
index 67da934072d29e19d6b5c085e4e6bc4478b4b02f..2b6de3363b7e68f7a7a9acaa6e534f0ba744f579 100644 (file)
@@ -1,5 +1,4 @@
 // RUN: clang -fsyntax-only -verify -std=c++98 %s 
-// XFAIL
 // fails due to exact diagnostic matching
 namespace A {
   struct C {
@@ -10,8 +9,8 @@ namespace A {
 }
 
 A:: ; // expected-error {{expected unqualified-id}}
-::A::ax::undef ex3; // expected-error {{expected a class or namespace}} expected-error {{expected '=', ',', ';', 'asm', or '__attribute__' after declarator}}
-A::undef1::undef2 ex4; // expected-error {{no member named 'undef1'}} expected-error {{expected '=', ',', ';', 'asm', or '__attribute__' after declarator}}
+::A::ax::undef ex3; // expected-error {{expected a class or namespace}} expected-error {{invalid token after top level declarator}}
+A::undef1::undef2 ex4; // expected-error {{no member named 'undef1'}} expected-error {{invalid token after top level declarator}}
 
 class C2 {
   void m(); // expected-note{{member declaration nearly matches}}
@@ -89,7 +88,8 @@ void f6(int A2::RC::x); // expected-error{{parameter declarator cannot be qualif
 
 int A2::RC::x; // expected-error{{non-static data member defined out-of-line}}
 
-void A2::CC::NC::m(); // expected-error{{out-of-line declaration of a member must be a definition}}
+void A2::CC::NC::m(); // expected-error{{out-of-line declaration of a member must be a definition}} \
+     //  expected-error{{out-of-line declaration of a member must be a definition}}
 
 
 namespace E {
@@ -150,3 +150,6 @@ namespace N {
 void ::global_func2(int) { } // expected-error{{definition or redeclaration of 'global_func2' cannot name the global scope}}
 
 void N::f() { } // okay
+
+X::X() : a(5) { } // expected-error{{use of undeclared identifier 'X'}} \
+      // expected-error{{expected function body after function declarator}}