[PATCH] D12444: [Sema] Avoid crash on tag-type mismatch (Fixes PR24610)

Vedant Kumar via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 31 13:44:22 PDT 2015


vsk updated the summary for this revision.
vsk updated this revision to Diff 33623.
vsk added a comment.

- Keep the assert, return early if the declaration is invalid.


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
@@ -3560,6 +3560,9 @@
 
 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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12444.33623.patch
Type: text/x-patch
Size: 976 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150831/d9ecfb9d/attachment.bin>


More information about the cfe-commits mailing list