re PR c++/89405 (ICE in import_export_decl, at cp/decl2.c:2959)
authorJakub Jelinek <jakub@redhat.com>
Thu, 21 Feb 2019 00:08:59 +0000 (01:08 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 21 Feb 2019 00:08:59 +0000 (01:08 +0100)
PR c++/89405
* decl.c (maybe_commonize_var): When clearing TREE_PUBLIC and
DECL_COMMON, set DECL_INTERFACE_KNOWN.

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

From-SVN: r269058

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;