aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2017-11-06 17:45:55 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2017-11-06 17:45:55 +0000
commit65371a7eddd37f9d5d15790486296cb441cabb40 (patch)
tree5ddd98710b5dd3186f8f660b2a84f275c1ab389d
parentd3722bf7325e1cf63215d69fda8d0667e4bb0321 (diff)
downloadgcc-65371a7eddd37f9d5d15790486296cb441cabb40.zip
gcc-65371a7eddd37f9d5d15790486296cb441cabb40.tar.gz
gcc-65371a7eddd37f9d5d15790486296cb441cabb40.tar.bz2
re PR c++/65579 ([C++11] gcc requires definition of a static constexpr member even though it is not odr-used)
/cp 2017-11-06 Paolo Carlini <paolo.carlini@oracle.com> PR c++/65579 * decl2.c (finish_static_data_member_decl): If there's an initializer, complete the type and re-apply the quals. /testsuite 2017-11-06 Paolo Carlini <paolo.carlini@oracle.com> PR c++/65579 * g++.dg/cpp0x/constexpr-template11.C: New. From-SVN: r254461
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl2.c9
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-template11.C16
4 files changed, 36 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index bb90b5a..2a6143a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2017-11-06 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/65579
+ * decl2.c (finish_static_data_member_decl): If there's an initializer,
+ complete the type and re-apply the quals.
+
2017-11-06 Martin Liska <mliska@suse.cz>
PR middle-end/82404
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index a23b96c..0b18308 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -787,6 +787,15 @@ finish_static_data_member_decl (tree decl,
&& TYPE_DOMAIN (TREE_TYPE (decl)) == NULL_TREE)
SET_VAR_HAD_UNKNOWN_BOUND (decl);
+ if (init)
+ {
+ /* Similarly to start_decl_1, we want to complete the type in order
+ to do the right thing in cp_apply_type_quals_to_decl, possibly
+ clear TYPE_QUAL_CONST (c++/65579). */
+ tree type = TREE_TYPE (decl) = complete_type (TREE_TYPE (decl));
+ cp_apply_type_quals_to_decl (cp_type_quals (type), decl);
+ }
+
cp_finish_decl (decl, init, init_const_expr_p, asmspec_tree, flags);
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index edb3797..b8f7d93 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-11-06 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/65579
+ * g++.dg/cpp0x/constexpr-template11.C: New.
+
2017-11-06 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/82838
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-template11.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-template11.C
new file mode 100644
index 0000000..0ad4908
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-template11.C
@@ -0,0 +1,16 @@
+// PR c++/65579
+// { dg-do link { target c++11 } }
+
+template <typename>
+struct S {
+ int i;
+};
+
+struct T {
+ static constexpr S<int> s = { 1 };
+};
+
+int main()
+{
+ return T::s.i;
+}