summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorppalka <ppalka@138bc75d-0d04-0410-961f-82ee72b054a4>2016-03-22 00:30:57 +0000
committerppalka <ppalka@138bc75d-0d04-0410-961f-82ee72b054a4>2016-03-22 00:30:57 +0000
commitc8e3e744939ed08d70ca7a21f5601a55a7654103 (patch)
treeaf672fb47ac92ddcd639ed7b300f915292b19432
parent8912988c86a2c5421d2ceec3ad8f012f6a5bd9be (diff)
downloadgcc-c8e3e744939ed08d70ca7a21f5601a55a7654103.tar.gz
Fix PR c++/70204 (ICE in non_const_var_error)
gcc/cp/ChangeLog: PR c++/70204 * constexpr.c (non_const_var_error): Check DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P. gcc/testsuite/ChangeLog: PR c++/70204 * g++.dg/cpp0x/constexpr-70204a.C: New test. * g++.dg/cpp0x/constexpr-70204b.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@234390 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/constexpr.c3
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-70204a.C18
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-70204b.C10
5 files changed, 42 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index c8919f9437e..578fc6fba35 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2016-03-22 Patrick Palka <ppalka@gcc.gnu.org>
+
+ PR c++/70204
+ * constexpr.c (non_const_var_error): Check
+ DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P.
+
2016-03-21 Richard Henderson <rth@redhat.com>
PR c++/70273
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 1f496b5f9bd..7b136330b3f 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -2763,7 +2763,8 @@ non_const_var_error (tree r)
inform (DECL_SOURCE_LOCATION (r),
"%q#D is volatile", r);
else if (!DECL_INITIAL (r)
- || !TREE_CONSTANT (DECL_INITIAL (r)))
+ || !TREE_CONSTANT (DECL_INITIAL (r))
+ || !DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (r))
inform (DECL_SOURCE_LOCATION (r),
"%qD was not initialized with a constant "
"expression", r);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e05b897a9b8..69c97a7fa36 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2016-03-22 Patrick Palka <ppalka@gcc.gnu.org>
+
+ PR c++/70204
+ * g++.dg/cpp0x/constexpr-70204a.C: New test.
+ * g++.dg/cpp0x/constexpr-70204b.C: New test.
+
2016-03-21 Jakub Jelinek <jakub@redhat.com>
PR middle-end/70326
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-70204a.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-70204a.C
new file mode 100644
index 00000000000..5ac551927e1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-70204a.C
@@ -0,0 +1,18 @@
+// PR c++/70204
+// { dg-do compile { target c++11 } }
+
+int a;
+
+template < int N, int I >
+void fn1 ()
+{
+ const int x = I * a, y = x;
+ fn1 < y, I > (); // { dg-error "constant|no match" }
+}
+
+int
+main ()
+{
+ fn1 < 0, 0 > ();
+ return 0;
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-70204b.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-70204b.C
new file mode 100644
index 00000000000..2b07d4fec9e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-70204b.C
@@ -0,0 +1,10 @@
+// PR c++/70204
+// { dg-do compile { target c++11 } }
+
+int a;
+
+void fn1 ()
+{
+ const int x = 0 * a;
+ constexpr int y = x; // { dg-error "constant" }
+}