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

llvm-svn: 288207
This commit is contained in:
Hans Wennborg 2016-11-29 22:31:00 +00:00
parent 47f7f30df9
commit a6714922d1
2 changed files with 7 additions and 0 deletions

View 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)

View 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'}}