]> gcc.gnu.org Git - gcc.git/commitdiff
backport: re PR c/88568 ('dllimport' no longer implies 'extern' in C)
authorJakub Jelinek <jakub@redhat.com>
Fri, 30 Aug 2019 12:14:46 +0000 (14:14 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 30 Aug 2019 12:14:46 +0000 (14:14 +0200)
Backported from mainline
2019-03-09  Jakub Jelinek  <jakub@redhat.com>

PR c/88568
* tree.c (handle_dll_attribute): Don't clear TREE_STATIC for
dllimport on VAR_DECLs with RECORD_TYPE or UNION_TYPE DECL_CONTEXT.

* g++.dg/other/pr88568.C: New test.

From-SVN: r275126

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/pr88568.C [new file with mode: 0644]
gcc/tree.c

index d0bfafb00c693b7cf4ad8c1b7f512beee647446e..0be8ee2f152db3cebb96e44895ecda4eab93ece7 100644 (file)
@@ -1,6 +1,12 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2019-03-09  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/88568
+       * tree.c (handle_dll_attribute): Don't clear TREE_STATIC for
+       dllimport on VAR_DECLs with RECORD_TYPE or UNION_TYPE DECL_CONTEXT.
+
        2019-03-05  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/89587
index 48dfeb3a1d1b2fa1fba132dd221e5bade3da1515..e08f576ae4560eac5a6a7f6c99292c953d47d96e 100644 (file)
@@ -1,6 +1,11 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2019-03-09  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/88568
+       * g++.dg/other/pr88568.C: New test.
+
        2019-03-08  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/82075
diff --git a/gcc/testsuite/g++.dg/other/pr88568.C b/gcc/testsuite/g++.dg/other/pr88568.C
new file mode 100644 (file)
index 0000000..9d344fd
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c/88568
+// { dg-do compile }
+// { dg-require-dll "" }
+
+struct S {
+  __attribute__((dllimport)) static const char foo[];
+};
+
+int
+foo (int x)
+{
+  return S::foo[x];
+}
index f92ce9ebce801a87f0d7f396c23d5cf41250020f..4b9cecb35930f3fa77494cf1f7ed40f772a89b51 100644 (file)
@@ -6456,8 +6456,11 @@ handle_dll_attribute (tree * pnode, tree name, tree args, int flags,
             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;
+         /* Clear TREE_STATIC because DECL_EXTERNAL is set, unless
+            it is a C++ static data member.  */
+         if (DECL_CONTEXT (node) == NULL_TREE
+             || !RECORD_OR_UNION_TYPE_P (DECL_CONTEXT (node)))
+           TREE_STATIC (node) = 0;
        }
 
       if (*no_add_attrs == false)
This page took 0.083837 seconds and 5 git commands to generate.