[PATCH] D12444: [Sema] Avoid crash on tag-type mismatch (Fixes PR24610)
Vedant Kumar via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 28 11:51:41 PDT 2015
vsk created this revision.
vsk added a subscriber: cfe-commits.
We currently assert-fail on the following input:
enum Color { R, G, B };
typedef struct Color C;
This patch just changes the assert to a conditional.
https://llvm.org/bugs/show_bug.cgi?id=24610
http://reviews.llvm.org/D12444
Files:
lib/Sema/SemaDecl.cpp
test/Sema/enum.c
Index: test/Sema/enum.c
===================================================================
--- test/Sema/enum.c
+++ test/Sema/enum.c
@@ -119,3 +119,7 @@
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}}
Index: lib/Sema/SemaDecl.cpp
===================================================================
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -3568,7 +3568,8 @@
return;
// A well-formed anonymous tag must always be a TUK_Definition.
- assert(TagFromDeclSpec->isThisDeclarationADefinition());
+ if (!TagFromDeclSpec->isThisDeclarationADefinition())
+ return;
// The type must match the tag exactly; no qualifiers allowed.
if (!Context.hasSameType(NewTD->getUnderlyingType(),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12444.33453.patch
Type: text/x-patch
Size: 994 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150828/84650234/attachment.bin>
More information about the cfe-commits
mailing list