re PR c++/22434 (ICE in simplify_{,gen_}subreg)
authorMark Mitchell <mark@codesourcery.com>
Thu, 3 Nov 2005 01:25:13 +0000 (01:25 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Thu, 3 Nov 2005 01:25:13 +0000 (01:25 +0000)
PR c++/22434
* call.c (build_conditional_expr): Do bad conversions, if there's
no other choice.
PR c++/22434
* g++.dg/expr/cond8.C: New test.

From-SVN: r106418

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/expr/cond8.C [new file with mode: 0644]

index 8d2ab78..eb52015 100644 (file)
@@ -1,5 +1,9 @@
 2005-11-02  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/22434
+       * call.c (build_conditional_expr): Do bad conversions, if there's
+       no other choice.
+
        PR c++/24560
        * parser.c (cp_parser_postfix_dot_deref_expression): Improve error
        message for use of overloaded functions on LHS of "." operator.
index 77cbe2a..99b8bcb 100644 (file)
@@ -3281,13 +3281,13 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3)
          error ("operands to ?: have different types");
          result = error_mark_node;
        }
-      else if (conv2 && !conv2->bad_p)
+      else if (conv2 && (!conv2->bad_p || !conv3))
        {
          arg2 = convert_like (conv2, arg2);
          arg2 = convert_from_reference (arg2);
          arg2_type = TREE_TYPE (arg2);
        }
-      else if (conv3 && !conv3->bad_p)
+      else if (conv3 && (!conv3->bad_p || !conv2))
        {
          arg3 = convert_like (conv3, arg3);
          arg3 = convert_from_reference (arg3);
index e71f25c..b52603b 100644 (file)
@@ -1,5 +1,8 @@
 2005-11-02  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/22434
+       * g++.dg/expr/cond8.C: New test.
+
        PR c++/24560
        * g++.dg/parse/dot1.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/expr/cond8.C b/gcc/testsuite/g++.dg/expr/cond8.C
new file mode 100644 (file)
index 0000000..f05c81a
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/22434
+// { dg-options "" }
+
+struct A
+{
+  A(void*);
+  ~A();
+};
+
+void foo(const int i, bool b)
+{
+  b ? A(0) : i; // { dg-error "conversion|initializing" } 
+}