]> granicus.if.org Git - clang/commitdiff
Don't try to merge DLL attributes on redeclaration of invalid decl (PR31069)
authorHans Wennborg <hans@hanshq.net>
Tue, 29 Nov 2016 22:31:00 +0000 (22:31 +0000)
committerHans Wennborg <hans@hanshq.net>
Tue, 29 Nov 2016 22:31:00 +0000 (22:31 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@288207 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/Sema/dllimport.c

index 58776e8705b617048f6b1f9179118d0dcc97afd9..e8764a0edf57ae26a65872da11f5b6294319e0aa 100644 (file)
@@ -5651,6 +5651,9 @@ static void checkDLLAttributeRedeclaration(Sema &S, NamedDecl *OldDecl,
                                            NamedDecl *NewDecl,
                                            bool IsSpecialization,
                                            bool IsDefinition) {
+  if(OldDecl->isInvalidDecl())
+    return;
+
   if (TemplateDecl *OldTD = dyn_cast<TemplateDecl>(OldDecl)) {
     OldDecl = OldTD->getTemplatedDecl();
     if (!IsSpecialization)
index 0728cf14a8e3f8eddae5b72e4edcaef3c3acf9ff..a7fb00e3f773c5530d92ec6b5a76cb242faea109 100644 (file)
@@ -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'}}