aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2006-06-16 02:33:35 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2006-06-16 02:33:35 +0000
commit2954333afc6cbb12f5628368b5f557a5730d1242 (patch)
tree94e1a3c01c007f49cf8e800c566242a2eb9a9642 /gcc
parenta95799ec5fe4e00d99fc1545ff0ea64d10e7e0b9 (diff)
downloadgcc-2954333afc6cbb12f5628368b5f557a5730d1242.zip
gcc-2954333afc6cbb12f5628368b5f557a5730d1242.tar.gz
gcc-2954333afc6cbb12f5628368b5f557a5730d1242.tar.bz2
re PR c++/27666 (ICE with volatile in conditional expression)
PR c++/27666 * call.c (build_conditional_expr): Robustify. PR c++/27666 * g++.dg/expr/cond9.C: New test. From-SVN: r114702
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/call.c9
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/expr/cond9.C10
4 files changed, 25 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f80d362..778658af 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
2006-06-15 Mark Mitchell <mark@codesourcery.com>
+ PR c++/27666
+ * call.c (build_conditional_expr): Robustify.
+
PR c++/27640
* pt.c (instantiate_template): Set processing_template_decl to
zero while performing substitutions.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index db8dd21..cd82732 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -3322,12 +3322,21 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3)
arg2 = convert_like (conv2, arg2);
arg2 = convert_from_reference (arg2);
arg2_type = TREE_TYPE (arg2);
+ /* Even if CONV2 is a valid conversion, the result of the
+ conversion may be invalid. For example, if ARG3 has type
+ "volatile X", and X does not have a copy constructor
+ accepting a "volatile X&", then even if ARG2 can be
+ converted to X, the conversion will fail. */
+ if (error_operand_p (arg2))
+ result = error_mark_node;
}
else if (conv3 && (!conv3->bad_p || !conv2))
{
arg3 = convert_like (conv3, arg3);
arg3 = convert_from_reference (arg3);
arg3_type = TREE_TYPE (arg3);
+ if (error_operand_p (arg3))
+ result = error_mark_node;
}
/* Free all the conversions we allocated. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9f056c3..0696d9a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2006-06-15 Mark Mitchell <mark@codesourcery.com>
+ PR c++/27666
+ * g++.dg/expr/cond9.C: New test.
+
PR c++/27640
* g++.dg/template/ctor7.C: New test.
diff --git a/gcc/testsuite/g++.dg/expr/cond9.C b/gcc/testsuite/g++.dg/expr/cond9.C
new file mode 100644
index 0000000..9e8f08c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/expr/cond9.C
@@ -0,0 +1,10 @@
+// PR c++/27666
+
+struct A { // { dg-error "A" }
+ A(int); // { dg-error "A" }
+};
+
+void foo(volatile A a) {
+ 1 ? a : 0; // { dg-error "match|temporary" }
+ 1 ? 0 : a; // { dg-error "match|temporary" }
+}