aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@gcc.gnu.org>2000-10-22 16:21:41 -0400
committerJason Merrill <jason@gcc.gnu.org>2000-10-22 16:21:41 -0400
commitdb5ae31b195c729dffebe3f057a4d1f5aa43427a (patch)
tree4816e341ce34ab64f67e5da8be64fc37119be63e /gcc
parent3e555c7de168afdaea775332c81ee925cb66738e (diff)
downloadgcc-db5ae31b195c729dffebe3f057a4d1f5aa43427a.zip
gcc-db5ae31b195c729dffebe3f057a4d1f5aa43427a.tar.gz
gcc-db5ae31b195c729dffebe3f057a4d1f5aa43427a.tar.bz2
call.c (build_conditional_expr): Use ocp_convert to force rvalue conversion.
* call.c (build_conditional_expr): Use ocp_convert to force rvalue conversion. From-SVN: r37009
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/call.c11
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/volatile1.C19
2 files changed, 27 insertions, 3 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 5af56a4..af79984 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -3036,16 +3036,21 @@ build_conditional_expr (arg1, arg2, arg3)
We need to force the lvalue-to-rvalue conversion here for class types,
so we get TARGET_EXPRs; trying to deal with a COND_EXPR of class rvalues
that isn't wrapped with a TARGET_EXPR plays havoc with exception
- regions. */
+ regions.
+
+ We use ocp_convert rather than build_user_type_conversion because the
+ latter returns NULL_TREE on failure, while the former gives an error. */
if (IS_AGGR_TYPE (TREE_TYPE (arg2)) && real_lvalue_p (arg2))
- arg2 = build_user_type_conversion (TREE_TYPE (arg2), arg2, LOOKUP_NORMAL);
+ arg2 = ocp_convert (TREE_TYPE (arg2), arg2,
+ CONV_IMPLICIT|CONV_FORCE_TEMP, LOOKUP_NORMAL);
else
arg2 = decay_conversion (arg2);
arg2_type = TREE_TYPE (arg2);
if (IS_AGGR_TYPE (TREE_TYPE (arg3)) && real_lvalue_p (arg3))
- arg3 = build_user_type_conversion (TREE_TYPE (arg3), arg3, LOOKUP_NORMAL);
+ arg3 = ocp_convert (TREE_TYPE (arg3), arg3,
+ CONV_IMPLICIT|CONV_FORCE_TEMP, LOOKUP_NORMAL);
else
arg3 = decay_conversion (arg3);
arg3_type = TREE_TYPE (arg3);
diff --git a/gcc/testsuite/g++.old-deja/g++.other/volatile1.C b/gcc/testsuite/g++.old-deja/g++.other/volatile1.C
new file mode 100644
index 0000000..c85a394
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.other/volatile1.C
@@ -0,0 +1,19 @@
+// Test that failed lvalue-to-rvalue conversion of vf doesn't crash the
+// compiler.
+
+class f_class
+{ }; // ERROR - candidates
+
+volatile f_class
+ret_v_f_class()
+{
+ f_class t;
+ return t;
+}
+
+int main(void)
+{
+ volatile f_class vf;
+ 0 ? ret_v_f_class() : vf; // ERROR - can't copy volatile lvalue
+ return 0;
+}