aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-04-22 18:52:25 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-04-22 18:52:25 +0000
commitb65abda449dfb17aba39794be6ce41111d40fda0 (patch)
tree4b5ad774cee3d09e7f493fe788bb3127f89601ca
parente970c60dadaf22019743724bac879dbefbc4f5e3 (diff)
Don't enter a qualified scope for an invalid decl.
Fixes assertion later on. rdar://9122937 & http://llvm.org/PR9459 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130006 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaDeclCXX.cpp4
-rw-r--r--test/SemaCXX/PR9459.cpp9
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 88193f5464..53a7c73998 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -7639,7 +7639,7 @@ bool Sema::CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange) {
/// 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 @@ void Sema::ActOnCXXEnterDeclInitializer(Scope *S, Decl *D) {
/// 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);
diff --git a/test/SemaCXX/PR9459.cpp b/test/SemaCXX/PR9459.cpp
new file mode 100644
index 0000000000..33cb2e5bc2
--- /dev/null
+++ b/test/SemaCXX/PR9459.cpp
@@ -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}}