On Thu, 10 Jan 2019, Jakub Jelinek wrote:

> Hi!
> 
> handle_dll_attribute sets DECL_EXTERNAL on node for "dllimport" on
> VAR_DECLs, it wants to handle those as if those vars are actually declared
> extern.  The problem is that it doesn't clear TREE_STATIC on them, which
> is what is normally the case on VAR_DECLs that are DECL_EXTERNAL and so
> the C FE that checks for incomplete structs and uses TREE_STATIC incorrectly
> diagnoses that.
> Joseph said in the PR that DECL_EXTERNAL + TREE_STATIC combination is for
> gnu_inline extern inlines, where it indeed makes sense, there is an external
> definition and a static alternative for that, but for the VAR_DECLs nothing
> like that makes sense.
> 
> I have no idea under what maintainership this falls into, because it is
> in middle-end code, but handle_dll_attribute seems to be very Windows
> specific.
> 
> JonY said in the PR that testing went well.
> 
> Ok for trunk?

OK.

Richard.

> 2019-01-10  Jakub Jelinek  <ja...@redhat.com>
> 
>       PR c/88568
>       * attribs.c (handle_dll_attribute): Clear TREE_STATIC after setting
>       DECL_EXTERNAL.
> 
>       * gcc.dg/pr88568.c: New test.
> 
> --- gcc/attribs.c.jj  2019-01-05 12:06:12.055124090 +0100
> +++ gcc/attribs.c     2019-01-07 12:57:09.739782281 +0100
> @@ -1691,6 +1691,8 @@ handle_dll_attribute (tree * pnode, tree
>            a function global scope, unless declared static.  */
>         if (current_function_decl != NULL_TREE && !TREE_STATIC (node))
>           TREE_PUBLIC (node) = 1;
> +       /* Clear TREE_STATIC because DECL_EXTERNAL is set.  */
> +       TREE_STATIC (node) = 0;
>       }
>  
>        if (*no_add_attrs == false)
> --- gcc/testsuite/gcc.dg/pr88568.c.jj 2019-01-07 13:00:43.113279882 +0100
> +++ gcc/testsuite/gcc.dg/pr88568.c    2019-01-07 13:00:16.494718463 +0100
> @@ -0,0 +1,4 @@
> +/* PR c/88568 */
> +/* { dg-do compile } */
> +/* { dg-require-dll "" } */
> +__attribute__((dllimport)) struct S var;     /* { dg-bogus "storage size of 
> .var. isn.t known" } */
> 
>       Jakub
> 
> 

-- 
Richard Biener <rguent...@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 
21284 (AG Nuernberg)

Reply via email to