summarylogtreecommitdiffstats
path: root/gcc9-pr88568-2.patch
diff options
context:
space:
mode:
Diffstat (limited to 'gcc9-pr88568-2.patch')
-rw-r--r--gcc9-pr88568-2.patch40
1 files changed, 40 insertions, 0 deletions
diff --git a/gcc9-pr88568-2.patch b/gcc9-pr88568-2.patch
new file mode 100644
index 000000000000..30b2e9e80ac0
--- /dev/null
+++ b/gcc9-pr88568-2.patch
@@ -0,0 +1,40 @@
+2019-03-05 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/88568
+ * attribs.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.
+
+--- gcc/attribs.c.jj 2019-01-10 11:44:07.122511397 +0100
++++ gcc/attribs.c 2019-03-05 13:59:51.745924578 +0100
+@@ -1691,8 +1691,11 @@ 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;
++ /* 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)
+--- gcc/testsuite/g++.dg/other/pr88568.C.jj 2019-03-05 14:03:20.132509560 +0100
++++ gcc/testsuite/g++.dg/other/pr88568.C 2019-03-05 14:01:39.674155860 +0100
+@@ -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];
++}