[cfe-commits] r130006 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/SemaCXX/PR9459.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Fri Apr 22 11:52:25 PDT 2011


Author: akirtzidis
Date: Fri Apr 22 13:52:25 2011
New Revision: 130006

URL: http://llvm.org/viewvc/llvm-project?rev=130006&view=rev
Log:
Don't enter a qualified scope for an invalid decl.

Fixes assertion later on. rdar://9122937 & http://llvm.org/PR9459

Added:
    cfe/trunk/test/SemaCXX/PR9459.cpp
Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=130006&r1=130005&r2=130006&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Apr 22 13:52:25 2011
@@ -7639,7 +7639,7 @@
 /// class X.
 void Sema::ActOnCXXEnterDeclInitializer(Scope *S, Decl *D) {
   // If there is no declaration, there was an error parsing it.
-  if (D == 0) return;
+  if (D == 0 || D->isInvalidDecl()) return;
 
   // We should only get called for declarations with scope specifiers, like:
   //   int foo::bar;
@@ -7651,7 +7651,7 @@
 /// initializer for the out-of-line declaration 'D'.
 void Sema::ActOnCXXExitDeclInitializer(Scope *S, Decl *D) {
   // If there is no declaration, there was an error parsing it.
-  if (D == 0) return;
+  if (D == 0 || D->isInvalidDecl()) return;
 
   assert(D->isOutOfLine());
   ExitDeclaratorContext(S);

Added: cfe/trunk/test/SemaCXX/PR9459.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/PR9459.cpp?rev=130006&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/PR9459.cpp (added)
+++ cfe/trunk/test/SemaCXX/PR9459.cpp Fri Apr 22 13:52:25 2011
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Don't crash.
+
+template<typename>struct ae_same; // expected-note {{declared here}}
+template<typename>struct ts{}ap()
+{ts<a>::ap<ae_same<int>::&ae_same<>>::p(a); }; // expected-error 2 {{undeclared identifier}} \
+    // expected-error 2 {{expected}} expected-error {{a space is required}} \
+    // expected-error 2 {{global}} expected-error {{too few}}





More information about the cfe-commits mailing list