r288207 - Don't try to merge DLL attributes on redeclaration of invalid decl (PR31069)

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 29 14:31:00 PST 2016


Author: hans
Date: Tue Nov 29 16:31:00 2016
New Revision: 288207

URL: http://llvm.org/viewvc/llvm-project?rev=288207&view=rev
Log:
Don't try to merge DLL attributes on redeclaration of invalid decl (PR31069)

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/Sema/dllimport.c

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=288207&r1=288206&r2=288207&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Nov 29 16:31:00 2016
@@ -5651,6 +5651,9 @@ static void checkDLLAttributeRedeclarati
                                            NamedDecl *NewDecl,
                                            bool IsSpecialization,
                                            bool IsDefinition) {
+  if(OldDecl->isInvalidDecl())
+    return;
+
   if (TemplateDecl *OldTD = dyn_cast<TemplateDecl>(OldDecl)) {
     OldDecl = OldTD->getTemplatedDecl();
     if (!IsSpecialization)

Modified: cfe/trunk/test/Sema/dllimport.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/dllimport.c?rev=288207&r1=288206&r2=288207&view=diff
==============================================================================
--- cfe/trunk/test/Sema/dllimport.c (original)
+++ cfe/trunk/test/Sema/dllimport.c Tue Nov 29 16:31:00 2016
@@ -210,6 +210,10 @@ __declspec(dllimport) void redecl6();
                       void redecl7();
 __declspec(dllimport) inline void redecl7() {}
 
+// PR31069: Don't crash trying to merge attributes for redeclaration of invalid decl.
+void __declspec(dllimport) redecl8(unknowntype X); // expected-error{{unknown type name 'unknowntype'}}
+void redecl8(unknowntype X) { } // expected-error{{unknown type name 'unknowntype'}}
+
 // External linkage is required.
 __declspec(dllimport) static int staticFunc(); // expected-error{{'staticFunc' must have external linkage when declared 'dllimport'}}
 




More information about the cfe-commits mailing list