On Tue, Nov 29, 2016 at 2:31 PM, Hans Wennborg via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> 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;
> +
>

Formatting looks weird here.


>    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'}}
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to