From 738e58799c9a4816e560d36625b637a7ede024ec Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Sun, 28 Dec 2014 09:18:54 +0000 Subject: Sema: Don't crash when an inject class name has a nested redefinition We expected the type of a TagDecl to be a TagType, not an InjectedClassNameType. Introduced a helper method, Type::getAsTagDecl, to abstract away the difference; redefine Type::getAsCXXRecordDecl to be in terms of it. llvm-svn: 224898 --- clang/lib/Sema/SemaDecl.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'clang/lib/Sema/SemaDecl.cpp') diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index d4b87ba615e..834f157e04f 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -11599,9 +11599,8 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, } else { // If the type is currently being defined, complain // about a nested redefinition. - const TagType *Tag - = cast(Context.getTagDeclType(PrevTagDecl)); - if (Tag->isBeingDefined()) { + auto *TD = Context.getTagDeclType(PrevTagDecl)->getAsTagDecl(); + if (TD->isBeingDefined()) { Diag(NameLoc, diag::err_nested_redefinition) << Name; Diag(PrevTagDecl->getLocation(), diag::note_previous_definition); -- cgit v1.2.3