]> granicus.if.org Git - clang/commitdiff
HandleDeclarator() returns NULL for semantic disasters. Deal with it
authorDouglas Gregor <dgregor@apple.com>
Mon, 30 Apr 2012 18:13:01 +0000 (18:13 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 30 Apr 2012 18:13:01 +0000 (18:13 +0000)
when we're in an Objective-C container context. Fixes
<rdar://problem/11286701>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155836 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/SemaObjCXX/crash.mm [new file with mode: 0644]

index 09d9d34e3af24e1e9502e4bc632238c1cbed6072..6b18c98eca672ca13ea7f20ff53b240b54a2751d 100644 (file)
@@ -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 (file)
index 0000000..345f72e
--- /dev/null
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify 
+
+// <rdar://problem/11286701>
+namespace std {
+  template<typename T, typename U> class pair;
+}
+
+@interface NSObject
+@end
+
+@interface Test : NSObject
+@end
+
+@implementation Test
+
+struct EvilStruct {
+} // note the missing semicolon
+
+  typedef std::pair<int, int> IntegerPair; // expected-error{{typedef declarator cannot be qualified}} \
+// expected-error{{typedef name must be an identifier}} \
+// expected-error{{expected ';' after top level declarator}}
+
+@end