* decl.c (duplicate_decls): Always merge DECL_DECLARED_CONSTEXPR_P.
authorJason Merrill <jason@redhat.com>
Mon, 26 Aug 2019 18:03:26 +0000 (14:03 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 26 Aug 2019 18:03:26 +0000 (14:03 -0400)
From-SVN: r274932

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.dg/cpp0x/constexpr-redeclaration2.C [new file with mode: 0644]

index f0eb35c1e4ed4ed2b00cd9102e682a75628c44d8..162b2c81c75a71d0fca8f968109497c3e18ffdb3 100644 (file)
@@ -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.
index 9f7923871db42feb37dafcf84832789dc96ba066..847817029e443a2d871d72adf02ca9c5688456a6 100644 (file)
@@ -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 (file)
index 0000000..3d492fa
--- /dev/null
@@ -0,0 +1,5 @@
+// { dg-do compile { target c++11 } }
+
+constexpr float pi = 3.14;
+extern const float pi;
+constexpr float x = pi;