aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2012-10-03 16:21:20 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2012-10-03 16:21:20 +0200
commit75ab707c7532221207fb89647c555438166c6f89 (patch)
treea25c4a048d2a1b6eb4bf140ffce41e529962fb69
parent2352eadb81e329fad9adbead81db9203610aa19a (diff)
downloadgcc-75ab707c7532221207fb89647c555438166c6f89.zip
gcc-75ab707c7532221207fb89647c555438166c6f89.tar.gz
gcc-75ab707c7532221207fb89647c555438166c6f89.tar.bz2
re PR c++/54777 ([C++11] Comma operator in constexpr environment can cause ICE)
PR c++/54777 * semantics.c (cxx_eval_constant_expression) <case COMPOUND_EXPR>: If not ignoring the second operand, pass the original second operand and not one with stripped nops to cxx_eval_constant_expression. * g++.dg/cpp0x/constexpr-ref4.C: New test. From-SVN: r192036
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/semantics.c1
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-ref4.C18
4 files changed, 31 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f868739..223e42a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2012-10-03 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/54777
+ * semantics.c (cxx_eval_constant_expression) <case COMPOUND_EXPR>: If
+ not ignoring the second operand, pass the original second operand
+ and not one with stripped nops to cxx_eval_constant_expression.
+
2012-10-01 Jason Merrill <jason@redhat.com>
* decl.c (check_initializer): Set DECL_NONTRIVIALLY_INITIALIZED_P
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 1aa5a8b..68cbb4b 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -7740,6 +7740,7 @@ cxx_eval_constant_expression (const constexpr_call *call, tree t,
/* Check that the LHS is constant and then discard it. */
cxx_eval_constant_expression (call, op0, allow_non_constant,
false, non_constant_p);
+ op1 = TREE_OPERAND (t, 1);
r = cxx_eval_constant_expression (call, op1, allow_non_constant,
addr, non_constant_p);
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2120cb4..659fa53 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2012-10-03 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/54777
+ * g++.dg/cpp0x/constexpr-ref4.C: New test.
+
2012-10-02 Janus Weil <janus@gcc.gnu.org>
PR fortran/54778
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ref4.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ref4.C
new file mode 100644
index 0000000..6ae355a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ref4.C
@@ -0,0 +1,18 @@
+// PR c++/54777
+// { dg-options -std=c++0x }
+
+struct S
+{
+ int s[1];
+ constexpr const int &foo (unsigned i) { return (i < 1 ? 0 : throw 1), s[i]; }
+ constexpr const int &bar (unsigned i) { return i < 1 ? s[i] : (throw 0, s[i]); }
+};
+
+int
+main ()
+{
+ constexpr S a {};
+ constexpr int i = a.foo (0);
+ constexpr int j = a.bar (0);
+ static_assert (i == j, "Ouch");
+}