re PR c++/22434 (ICE in simplify_{,gen_}subreg)
authorJason Merrill <jason@redhat.com>
Fri, 9 May 2014 18:15:46 +0000 (14:15 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 9 May 2014 18:15:46 +0000 (14:15 -0400)
PR c++/22434
* call.c (build_conditional_expr_1): Don't try to pool cv-quals
if we didn't find a conversion.
Don't accept a bad conversion too early.

From-SVN: r210281

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/g++.dg/expr/cond8.C
gcc/testsuite/g++.old-deja/g++.jason/conversion10.C

index 3d400bbb7540717a95da4c8ccabba770112d7341..232ceec6ed1ac74fb859e8248c8a908b9008bcb9 100644 (file)
@@ -1,3 +1,10 @@
+2014-05-09  Jason Merrill  <jason@redhat.com>
+
+       PR c++/22434
+       * call.c (build_conditional_expr_1): Don't try to pool cv-quals
+       if we didn't find a conversion.
+       Don't accept a bad conversion too early.
+
 2014-05-08  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/13981
index 857df57c60ce519c73a1c44334a3293ac71f46e0..691e9e3ce90a8ff4bdb194cd8a066bcb4256d746 100644 (file)
@@ -4714,7 +4714,7 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3,
                      arg2_type, arg3_type);
          result = error_mark_node;
        }
-      else if (conv2 && (!conv2->bad_p || !conv3))
+      else if (conv2 && !conv2->bad_p)
        {
          arg2 = convert_like (conv2, arg2, complain);
          arg2 = convert_from_reference (arg2);
@@ -4727,7 +4727,7 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3,
          if (error_operand_p (arg2))
            result = error_mark_node;
        }
-      else if (conv3 && (!conv3->bad_p || !conv2))
+      else if (conv3 && !conv3->bad_p)
        {
          arg3 = convert_like (conv3, arg3, complain);
          arg3 = convert_from_reference (arg3);
@@ -4757,7 +4757,8 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3,
         conditional expression failing altogether, even though,
         according to this step, the one operand could be converted to
         the type of the other.  */
-      if ((conv2 || conv3)
+      if (((conv2 && !conv2->bad_p)
+          || (conv3 && !conv3->bad_p))
          && CLASS_TYPE_P (arg2_type)
          && cp_type_quals (arg2_type) != cp_type_quals (arg3_type))
        arg2_type = arg3_type =
index 3e089537ff86048b27800df3fc2ff0f15f8e25e7..11b090dfc5475c32f623153e48ab279369c7ad78 100644 (file)
@@ -1,13 +1,12 @@
 // PR c++/22434
-// { dg-options "" }
 
 struct A
 {
-  A(void*);                    // { dg-message "initializing" }
+  A(void*);
   ~A();
 };
 
 void foo(const int i, bool b)
 {
-  b ? A(0) : i; // { dg-error "conversion" }
+  b ? A(0) : i; // { dg-error "" }
 }
index 8cbba413da73d104bbc245ad2d6d6fcf3e336af7..0eeceebaae70780f44e70faa19353ff627cf9ff8 100644 (file)
@@ -1,4 +1,5 @@
 // { dg-do assemble  }
+// { dg-options "" }
 // PRMS Id: 9019
 // Bug: g++ doesn't find conversion to const char *.