aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2019-08-26 14:03:26 -0400
committerJason Merrill <jason@gcc.gnu.org>2019-08-26 14:03:26 -0400
commit59bce4ad03e438e81dcaa8ed956fbad6461c7d75 (patch)
treee239fb6bf858d27f1f093c3ddddbf221391fe95a
parentf7cf1751a9389bf5b1d69b41b07d31c1cfd9761d (diff)
downloadgcc-59bce4ad03e438e81dcaa8ed956fbad6461c7d75.zip
gcc-59bce4ad03e438e81dcaa8ed956fbad6461c7d75.tar.gz
gcc-59bce4ad03e438e81dcaa8ed956fbad6461c7d75.tar.bz2
* decl.c (duplicate_decls): Always merge DECL_DECLARED_CONSTEXPR_P.
From-SVN: r274932
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/decl.c5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-redeclaration2.C5
3 files changed, 11 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f0eb35c..162b2c8 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,7 @@
+2019-08-26 Jason Merrill <jason@redhat.com>
+
+ * decl.c (duplicate_decls): Always merge DECL_DECLARED_CONSTEXPR_P.
+
2019-08-26 Marek Polacek <polacek@redhat.com>
PR c++/91545 - ICE in constexpr store evaluation.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 9f79238..8478170 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -2204,9 +2204,8 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
SET_DECL_DEPENDENT_INIT_P (newdecl, true);
DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (newdecl)
|= DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (olddecl);
- if (DECL_CLASS_SCOPE_P (olddecl))
- DECL_DECLARED_CONSTEXPR_P (newdecl)
- |= DECL_DECLARED_CONSTEXPR_P (olddecl);
+ DECL_DECLARED_CONSTEXPR_P (newdecl)
+ |= DECL_DECLARED_CONSTEXPR_P (olddecl);
/* Merge the threadprivate attribute from OLDDECL into NEWDECL. */
if (DECL_LANG_SPECIFIC (olddecl)
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-redeclaration2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-redeclaration2.C
new file mode 100644
index 0000000..3d492fa
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-redeclaration2.C
@@ -0,0 +1,5 @@
+// { dg-do compile { target c++11 } }
+
+constexpr float pi = 3.14;
+extern const float pi;
+constexpr float x = pi;