summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2003-08-21 22:02:27 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2003-08-21 22:02:27 +0000
commit2472145e6963720d717cc7e15f88d2a5ef5a23c1 (patch)
tree9f3303b88fc85aa976aaff12457c14f2c18c87ce
parentc11a3f5e31b2bc2837267cef4835d292f2b388af (diff)
downloadgcc-2472145e6963720d717cc7e15f88d2a5ef5a23c1.tar.gz
PR c++/11283
* call.c (build_conditional_expr): Ignore cv-qual differences for non-class types. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@70667 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/call.c9
-rw-r--r--gcc/testsuite/g++.dg/conversion/cond6.C18
3 files changed, 31 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index ec4f44458bd..7eaf150b76a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2003-08-21 Jason Merrill <jason@redhat.com>
+
+ PR c++/11283
+ * call.c (build_conditional_expr): Ignore cv-qual differences for
+ non-class types.
+
2003-08-21 Mark Mitchell <mark@codesourcery.com>
PR c++/11551
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index a76d2ac022a..4bda8da36fc 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -3171,7 +3171,11 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3)
{
arg2 = convert_like (conv2, arg2);
arg2 = convert_from_reference (arg2);
- if (!same_type_p (TREE_TYPE (arg2), arg3_type))
+ if (!same_type_p (TREE_TYPE (arg2), arg3_type)
+ && CLASS_TYPE_P (arg3_type))
+ /* The types need to match if we're converting to a class type.
+ If not, we don't care about cv-qual mismatches, since
+ non-class rvalues are not cv-qualified. */
abort ();
arg2_type = TREE_TYPE (arg2);
}
@@ -3179,7 +3183,8 @@ 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))
+ if (!same_type_p (TREE_TYPE (arg3), arg2_type)
+ && CLASS_TYPE_P (arg2_type))
abort ();
arg3_type = TREE_TYPE (arg3);
}
diff --git a/gcc/testsuite/g++.dg/conversion/cond6.C b/gcc/testsuite/g++.dg/conversion/cond6.C
new file mode 100644
index 00000000000..8c05e1b143c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/conversion/cond6.C
@@ -0,0 +1,18 @@
+// PR c++/11283
+// Converting "a" to the type of "i" produces "int" rather than "const
+// int", which was causing build_conditional_expr to abort. But we don't
+// care about cv-quals on non-class rvalues.
+
+struct A
+{
+ operator int ();
+};
+
+extern A a;
+extern const int i;
+extern bool b;
+
+int f ()
+{
+ return b ? a : i;
+}