From e7be1090e8cc8bfcda4f73fcad35d29e9e58b1c4 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 30 Apr 2012 18:13:01 +0000 Subject: [PATCH] HandleDeclarator() returns NULL for semantic disasters. Deal with it when we're in an Objective-C container context. Fixes . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155836 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDecl.cpp | 2 +- test/SemaObjCXX/crash.mm | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 test/SemaObjCXX/crash.mm diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 09d9d34e3a..6b18c98eca 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -3233,7 +3233,7 @@ Decl *Sema::ActOnDeclarator(Scope *S, Declarator &D) { Decl *Dcl = HandleDeclarator(S, D, MultiTemplateParamsArg(*this)); if (OriginalLexicalContext && OriginalLexicalContext->isObjCContainer() && - Dcl->getDeclContext()->isFileContext()) + Dcl && Dcl->getDeclContext()->isFileContext()) Dcl->setTopLevelDeclInObjCContainer(); return Dcl; diff --git a/test/SemaObjCXX/crash.mm b/test/SemaObjCXX/crash.mm new file mode 100644 index 0000000000..345f72e609 --- /dev/null +++ b/test/SemaObjCXX/crash.mm @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -fsyntax-only %s -verify + +// +namespace std { + template class pair; +} + +@interface NSObject +@end + +@interface Test : NSObject +@end + +@implementation Test + +struct EvilStruct { +} // note the missing semicolon + + typedef std::pair IntegerPair; // expected-error{{typedef declarator cannot be qualified}} \ +// expected-error{{typedef name must be an identifier}} \ +// expected-error{{expected ';' after top level declarator}} + +@end -- 2.40.0