Skip to content

Commit

Permalink
HandleDeclarator() returns NULL for semantic disasters. Deal with it
Browse files Browse the repository at this point in the history
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
  • Loading branch information
DougGregor committed Apr 30, 2012
1 parent 694e796 commit e7be109
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
23 changes: 23 additions & 0 deletions test/SemaObjCXX/crash.mm
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e7be109

Please sign in to comment.