]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/89405
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 21 Feb 2019 00:08:59 +0000 (00:08 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 21 Feb 2019 00:08:59 +0000 (00:08 +0000)
* decl.c (maybe_commonize_var): When clearing TREE_PUBLIC and
DECL_COMMON, set DECL_INTERFACE_KNOWN.

* g++.dg/cpp1z/inline-var5.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@269058 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1z/inline-var5.C [new file with mode: 0644]

index fabcb1a5b4c191a5834dbdb5571ef1ce1fdf502d..58df2b5953cbc464ae8ba6cbde0653d034bd370d 100644 (file)
@@ -1,5 +1,9 @@
 2019-02-20  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/89405
+       * decl.c (maybe_commonize_var): When clearing TREE_PUBLIC and
+       DECL_COMMON, set DECL_INTERFACE_KNOWN.
+
        PR c++/89336
        * constexpr.c (cxx_eval_store_expression): Diagnose changing of active
        union member for -std=c++17 and earlier.
index c164975318b61ccb400f88c3b8bf930172c0bb00..acde010e3e529e7c5291dbaba831d9198670a00b 100644 (file)
@@ -5634,6 +5634,7 @@ maybe_commonize_var (tree decl)
                 be merged.  */
              TREE_PUBLIC (decl) = 0;
              DECL_COMMON (decl) = 0;
+             DECL_INTERFACE_KNOWN (decl) = 1;
              const char *msg;
              if (DECL_INLINE_VAR_P (decl))
                msg = G_("sorry: semantics of inline variable "
index 32a68cc71f4ef9202c909e70e48fa8b6f1ea4ded..d8d6ef94287bb942ceef461ff960dbde4f3e5934 100644 (file)
@@ -1,5 +1,8 @@
 2019-02-20  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/89405
+       * g++.dg/cpp1z/inline-var5.C: New test.
+
        PR middle-end/89412
        * gcc.c-torture/compile/pr89412.c: New test.
 
diff --git a/gcc/testsuite/g++.dg/cpp1z/inline-var5.C b/gcc/testsuite/g++.dg/cpp1z/inline-var5.C
new file mode 100644 (file)
index 0000000..111c978
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/89405
+// { dg-do compile { target c++17 } }
+// { dg-options "-fno-weak" }
+
+template <int N>
+struct S
+{
+  static constexpr int a = N;  // { dg-warning "semantics of inline variable" }
+};                             // { dg-message "you can work around this" "" { target *-*-* } .-1 }
+
+const int *x = &S<0>::a;