r246618 - [Sema] Avoid crash on tag-type mismatch (Fixes PR24610)
Vedant Kumar via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 1 20:27:16 PDT 2015
Author: vedantk
Date: Tue Sep 1 22:27:15 2015
New Revision: 246618
URL: http://llvm.org/viewvc/llvm-project?rev=246618&view=rev
Log:
[Sema] Avoid crash on tag-type mismatch (Fixes PR24610)
Differential Revision: http://reviews.llvm.org/D12444
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/enum.c
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=246618&r1=246617&r2=246618&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Sep 1 22:27:15 2015
@@ -3560,6 +3560,9 @@ void Sema::handleTagNumbering(const TagD
void Sema::setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec,
TypedefNameDecl *NewTD) {
+ if (TagFromDeclSpec->isInvalidDecl())
+ return;
+
// Do nothing if the tag already has a name for linkage purposes.
if (TagFromDeclSpec->hasNameForLinkage())
return;
Modified: cfe/trunk/test/Sema/enum.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/enum.c?rev=246618&r1=246617&r2=246618&view=diff
==============================================================================
--- cfe/trunk/test/Sema/enum.c (original)
+++ cfe/trunk/test/Sema/enum.c Tue Sep 1 22:27:15 2015
@@ -119,3 +119,7 @@ void crash(enum E* e) // expected-warnin
typedef enum { NegativeShort = (short)-1 } NegativeShortEnum;
int NegativeShortTest[NegativeShort == -1 ? 1 : -1];
+
+// PR24610
+enum Color { Red, Green, Blue }; // expected-note{{previous use is here}}
+typedef struct Color NewColor; // expected-error {{use of 'Color' with tag type that does not match previous declaration}}
More information about the cfe-commits
mailing list