aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2003-05-05 17:11:13 -0400
committerJason Merrill <jason@gcc.gnu.org>2003-05-05 17:11:13 -0400
commit5f7262e693943229dfd8262e04b122a89b9cdd5f (patch)
treea0db13f0c60ffac95372c203de89c666923ee4f4 /gcc
parent9938b5d971c49e642b6050e427ba4e5816cec7d9 (diff)
downloadgcc-5f7262e693943229dfd8262e04b122a89b9cdd5f.zip
gcc-5f7262e693943229dfd8262e04b122a89b9cdd5f.tar.gz
gcc-5f7262e693943229dfd8262e04b122a89b9cdd5f.tar.bz2
re PR c++/9537 ([New parser] problem handling const return types)
PR c++/9537 * call.c (conditional_conversion): Build an RVALUE_CONV if we're just changing the cv-quals. (build_conditional_expr): Don't call convert to change cv-quals. From-SVN: r66502
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/call.c19
-rw-r--r--gcc/testsuite/g++.dg/conversion/cond3.C20
3 files changed, 40 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 3567da7..40a4de1 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+2003-05-05 Jason Merrill <jason@redhat.com>
+
+ PR c++/9537
+ * call.c (conditional_conversion): Build an RVALUE_CONV if
+ we're just changing the cv-quals.
+ (build_conditional_expr): Don't call convert to change
+ cv-quals.
+
2003-05-05 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/10496
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 2340d41..44683ff 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -3187,7 +3187,10 @@ conditional_conversion (tree e1, tree e2)
same cv-qualification as, or a greater cv-qualification than, the
cv-qualification of T1. If the conversion is applied, E1 is
changed to an rvalue of type T2 that still refers to the original
- source class object (or the appropriate subobject thereof). */
+ source class object (or the appropriate subobject thereof).
+
+ FIXME we can't express an rvalue that refers to the original object;
+ we have to create a new one. */
if (CLASS_TYPE_P (t1) && CLASS_TYPE_P (t2)
&& same_or_base_type_p (TYPE_MAIN_VARIANT (t2),
TYPE_MAIN_VARIANT (t1)))
@@ -3197,7 +3200,12 @@ conditional_conversion (tree e1, tree e2)
conv = build1 (IDENTITY_CONV, t1, e1);
if (!same_type_p (TYPE_MAIN_VARIANT (t1),
TYPE_MAIN_VARIANT (t2)))
- conv = build_conv (BASE_CONV, t2, conv);
+ {
+ conv = build_conv (BASE_CONV, t2, conv);
+ NEED_TEMPORARY_P (conv) = 1;
+ }
+ else
+ conv = build_conv (RVALUE_CONV, t2, conv);
return conv;
}
else
@@ -3337,11 +3345,8 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3)
{
arg2 = convert_like (conv2, arg2);
arg2 = convert_from_reference (arg2);
- /* That may not quite have done the trick. If the two types
- are cv-qualified variants of one another, we will have
- just used an IDENTITY_CONV. */
if (!same_type_p (TREE_TYPE (arg2), arg3_type))
- arg2 = convert (arg3_type, arg2);
+ abort ();
arg2_type = TREE_TYPE (arg2);
}
else if (conv3 && !ICS_BAD_FLAG (conv3))
@@ -3349,7 +3354,7 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3)
arg3 = convert_like (conv3, arg3);
arg3 = convert_from_reference (arg3);
if (!same_type_p (TREE_TYPE (arg3), arg2_type))
- arg3 = convert (arg2_type, arg3);
+ abort ();
arg3_type = TREE_TYPE (arg3);
}
}
diff --git a/gcc/testsuite/g++.dg/conversion/cond3.C b/gcc/testsuite/g++.dg/conversion/cond3.C
new file mode 100644
index 0000000..da052d4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/conversion/cond3.C
@@ -0,0 +1,20 @@
+// PR c++/9537
+
+class String
+{
+public:
+ String();
+ String( char *str );
+ operator char *();
+};
+
+const String operator+( String s1, String )
+{
+ return s1;
+}
+
+String valGlue(const String before)
+{
+ String ret;
+ return false ? ret : before + before;
+}