From 73ab3eb732462887817e000a23b86b8a24641c07 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 21 Feb 2019 01:08:59 +0100 Subject: [PATCH] re PR c++/89405 (ICE in import_export_decl, at cp/decl2.c:2959) 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 | 4 ++++ gcc/cp/decl.c | 1 + gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/cpp1z/inline-var5.C | 11 +++++++++++ 4 files changed, 19 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1z/inline-var5.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fabcb1a5b4c..58df2b5953c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2019-02-20 Jakub Jelinek + 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. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index c164975318b..acde010e3e5 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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 " diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 32a68cc71f4..d8d6ef94287 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2019-02-20 Jakub Jelinek + 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 index 00000000000..111c9788e84 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/inline-var5.C @@ -0,0 +1,11 @@ +// PR c++/89405 +// { dg-do compile { target c++17 } } +// { dg-options "-fno-weak" } + +template +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; -- 2.30.2