https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88568
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org,
| |jsm28 at gcc dot gnu.org,
| |jyong at gcc dot gnu.org
Summary|[8/9 Regression] |[7/8/9 Regression]
|'dllimport' no longer |'dllimport' no longer
|implies 'extern' in C |implies 'extern' in C
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Guess it regressed with the PR24293 change then.
I think the problem is that handle_dll_attribute has for dllimport on
VAR_DECLs:
/* `extern' needn't be specified with dllimport.
Specify `extern' now and hope for the best. Sigh. */
DECL_EXTERNAL (node) = 1;
/* Also, implicitly give dllimport'd variables declared within
a function global scope, unless declared static. */
if (current_function_decl != NULL_TREE && !TREE_STATIC (node))
TREE_PUBLIC (node) = 1;
The problem is that the decl is previously TREE_STATIC and TREE_PUBLIC and
setting it also DECL_EXTERNAL results in an unusual combination of flags.
So, either we can tweak the code reporting the issues and hope TREE_STATIC &&
DECL_EXTERNAL means something reasonable elsewhere:
--- gcc/c/c-decl.c.jj 2019-01-01 12:37:48.628458597 +0100
+++ gcc/c/c-decl.c 2019-01-04 15:13:03.281213304 +0100
@@ -5100,7 +5100,8 @@ finish_decl (tree decl, location_t init_
if ((RECORD_OR_UNION_TYPE_P (TREE_TYPE (decl))
|| TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
&& DECL_SIZE (decl) == NULL_TREE
- && TREE_STATIC (decl))
+ && TREE_STATIC (decl)
+ && !DECL_EXTERNAL (decl))
incomplete_record_decls.safe_push (decl);
if (is_global_var (decl) && DECL_SIZE (decl) != NULL_TREE)
or we should change handle_dll_attribute to:
--- gcc/attribs.c 2019-01-01 12:37:18.066960036 +0100
+++ gcc/attribs.c 2019-01-04 15:41:55.949812827 +0100
@@ -1691,6 +1691,7 @@ 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;
+ TREE_STATIC (node) = 0;
}
if (*no_add_attrs == false)
Joseph, is there any meaning for DECL_EXTERNAL & TREE_STATIC, or is that
invalid flag combination? If the latter, we should go with the latter patch,
but I'm afraid I have no access to Windows and no way to test.