This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH to build_conditional_expr for c++/11283
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 21 Aug 2003 18:03:39 -0400
- Subject: C++ PATCH to build_conditional_expr for c++/11283
We were failing to reconcile a ?: expression where one arm was a class with
a conversion to int, and the other was a const int variable. Converting
the first to match the second produced an int rvalue, which caused
build_conditional_expr to abort. But we don't care about cv-qual
differences for non-class rvalues. Fixed thus.
Tested x86_64-pc-linux-gnu, applied to trunk. Test in
g++.dg/conversion/cond6.C.
2003-08-21 Jason Merrill <jason@redhat.com>
PR c++/11283
* call.c (build_conditional_expr): Ignore cv-qual differences for
non-class types.
*** call.c.~1~ 2003-08-21 15:54:33.000000000 -0400
--- call.c 2003-08-21 16:58:41.000000000 -0400
*************** build_conditional_expr (tree arg1, tree
*** 3171,3177 ****
{
arg2 = convert_like (conv2, arg2);
arg2 = convert_from_reference (arg2);
! if (!same_type_p (TREE_TYPE (arg2), arg3_type))
abort ();
arg2_type = TREE_TYPE (arg2);
}
--- 3171,3181 ----
{
arg2 = convert_like (conv2, arg2);
arg2 = convert_from_reference (arg2);
! 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);
}
*************** build_conditional_expr (tree arg1, tree
*** 3179,3185 ****
{
arg3 = convert_like (conv3, arg3);
arg3 = convert_from_reference (arg3);
! if (!same_type_p (TREE_TYPE (arg3), arg2_type))
abort ();
arg3_type = TREE_TYPE (arg3);
}
--- 3183,3190 ----
{
arg3 = convert_like (conv3, arg3);
arg3 = convert_from_reference (arg3);
! if (!same_type_p (TREE_TYPE (arg3), arg2_type)
! && CLASS_TYPE_P (arg2_type))
abort ();
arg3_type = TREE_TYPE (arg3);
}