diff options
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 5 | ||||
| -rw-r--r-- | clang/test/Sema/dllimport.c | 7 |
2 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 7df9ed51804..9e5fa0e5634 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -5975,7 +5975,7 @@ static void checkDLLAttributeRedeclaration(Sema &S, NamedDecl *OldDecl, NamedDecl *NewDecl, bool IsSpecialization, bool IsDefinition) { - if (OldDecl->isInvalidDecl()) + if (OldDecl->isInvalidDecl() || NewDecl->isInvalidDecl()) return; bool IsTemplate = false; @@ -6081,7 +6081,8 @@ static void checkDLLAttributeRedeclaration(Sema &S, NamedDecl *OldDecl, NewDecl->dropAttr<DLLImportAttr>(); } } else if (IsInline && OldImportAttr && !IsMicrosoft) { - // In MinGW, seeing a function declared inline drops the dllimport attribute. + // In MinGW, seeing a function declared inline drops the dllimport + // attribute. OldDecl->dropAttr<DLLImportAttr>(); NewDecl->dropAttr<DLLImportAttr>(); S.Diag(NewDecl->getLocation(), diff --git a/clang/test/Sema/dllimport.c b/clang/test/Sema/dllimport.c index d05ed6ef3fa..53bf372c654 100644 --- a/clang/test/Sema/dllimport.c +++ b/clang/test/Sema/dllimport.c @@ -211,9 +211,14 @@ __declspec(dllimport) void redecl6(); void redecl7(); __declspec(dllimport) inline void redecl7() {} -// PR31069: Don't crash trying to merge attributes for redeclaration of invalid decl. +// 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'}} +// PR32021: Similarly, don't crash trying to merge attributes from a valid +// decl to an invalid redeclaration. +void __declspec(dllimport) redecl9(void); // expected-note{{previous declaration is here}} +int redecl9(void) {} // expected-error{{conflicting types for 'redecl9'}} // External linkage is required. __declspec(dllimport) static int staticFunc(); // expected-error{{'staticFunc' must have external linkage when declared 'dllimport'}} |

