/// 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;
/// 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);
--- /dev/null
+// 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}}