diff options
author | Jason Merrill <jason@gcc.gnu.org> | 2003-05-15 18:25:51 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2003-05-15 18:25:51 -0400 |
commit | 9cefd2cac4d33953331ee31b96553e0baca0d898 (patch) | |
tree | 97560f63f2cfb583065bc62291c070d43909a908 /gcc/cp/call.c | |
parent | 8f4b394d0259cb330bf8a67f0e4b974a6070def7 (diff) | |
download | gcc-9cefd2cac4d33953331ee31b96553e0baca0d898.zip gcc-9cefd2cac4d33953331ee31b96553e0baca0d898.tar.gz gcc-9cefd2cac4d33953331ee31b96553e0baca0d898.tar.bz2 |
re PR c++/5388 (Incorrect message "operands to ?: have different types")
PR c++/5388
* call.c (conditional_conversion): Don't consider implicit
conversions if T2 is a base of T1.
* cp-tree.h (DERIVED_FROM_P, UNIQUELY_DERIVED_FROM_P): Make boolean.
(ACCESSIBLY_UNIQUELY_DERIVED_P, PUBLICLY_UNIQUELY_DERIVED_P): Likewise.
* parser.c (cp_parser_primary_expression): Convert a static data
member from reference.
From-SVN: r66844
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r-- | gcc/cp/call.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 1d40e42..d40a60c 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -3161,6 +3161,7 @@ conditional_conversion (tree e1, tree e2) tree t1 = non_reference (TREE_TYPE (e1)); tree t2 = non_reference (TREE_TYPE (e2)); tree conv; + bool good_base; /* [expr.cond] @@ -3192,10 +3193,9 @@ conditional_conversion (tree e1, tree e2) 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))) + && ((good_base = DERIVED_FROM_P (t2, t1)) || DERIVED_FROM_P (t1, t2))) { - if (at_least_as_qualified_p (t2, t1)) + if (good_base && at_least_as_qualified_p (t2, t1)) { conv = build1 (IDENTITY_CONV, t1, e1); if (!same_type_p (TYPE_MAIN_VARIANT (t1), @@ -3211,13 +3211,13 @@ conditional_conversion (tree e1, tree e2) else return NULL_TREE; } + else + /* [expr.cond] - /* [expr.cond] - - E1 can be converted to match E2 if E1 can be implicitly converted - to the type that expression E2 would have if E2 were converted to - an rvalue (or the type it has, if E2 is an rvalue). */ - return implicit_conversion (t2, t1, e1, LOOKUP_NORMAL); + Otherwise: E1 can be converted to match E2 if E1 can be implicitly + converted to the type that expression E2 would have if E2 were + converted to an rvalue (or the type it has, if E2 is an rvalue). */ + return implicit_conversion (t2, t1, e1, LOOKUP_NORMAL); } /* Implement [expr.cond]. ARG1, ARG2, and ARG3 are the three |