OSDN Git Service

* cvt.c (convert_to_void): Handle null op1.
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 10 Feb 2011 16:29:58 +0000 (16:29 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 10 Feb 2011 16:29:58 +0000 (16:29 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@170007 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/cvt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/regress/ext-cond1.C [new file with mode: 0644]

index 26de2b6..7d9667d 100644 (file)
@@ -1,5 +1,7 @@
 2011-02-09  Jason Merrill  <jason@redhat.com>
 
+       * cvt.c (convert_to_void): Handle null op1.
+
        * class.c (type_has_constexpr_default_constructor): Make sure the
        caller stripped an enclosing array.
        * init.c (perform_member_init): Strip arrays before calling it.
index 029aec3..36c0703 100644 (file)
@@ -892,20 +892,24 @@ convert_to_void (tree expr, impl_conv_void implicit, tsubst_flags_t complain)
        /* The two parts of a cond expr might be separate lvalues.  */
        tree op1 = TREE_OPERAND (expr,1);
        tree op2 = TREE_OPERAND (expr,2);
-       bool side_effects = TREE_SIDE_EFFECTS (op1) || TREE_SIDE_EFFECTS (op2);
+       bool side_effects = ((op1 && TREE_SIDE_EFFECTS (op1))
+                            || TREE_SIDE_EFFECTS (op2));
        tree new_op1, new_op2;
+       new_op1 = NULL_TREE;
        if (implicit != ICV_CAST && !side_effects)
          {
-           new_op1 = convert_to_void (op1, ICV_SECOND_OF_COND, complain);
+           if (op1)
+             new_op1 = convert_to_void (op1, ICV_SECOND_OF_COND, complain);
            new_op2 = convert_to_void (op2, ICV_THIRD_OF_COND, complain);
          }
        else
          {
-           new_op1 = convert_to_void (op1, ICV_CAST, complain);
+           if (op1)
+             new_op1 = convert_to_void (op1, ICV_CAST, complain);
            new_op2 = convert_to_void (op2, ICV_CAST, complain);
          }
 
-       expr = build3 (COND_EXPR, TREE_TYPE (new_op1),
+       expr = build3 (COND_EXPR, TREE_TYPE (new_op2),
                       TREE_OPERAND (expr, 0), new_op1, new_op2);
        break;
       }
index 8d7e387..97d2caf 100644 (file)
@@ -1,5 +1,7 @@
 2011-02-09  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/cpp0x/regress/ext-cond1.C: Copy from ext/cond1.C.
+
        * g++.dg/cpp0x/regress/abi-empty7.C: New.
 
        * g++.dg/cpp0x/regress: New directory.
diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/ext-cond1.C b/gcc/testsuite/g++.dg/cpp0x/regress/ext-cond1.C
new file mode 100644 (file)
index 0000000..dc9814e
--- /dev/null
@@ -0,0 +1,4 @@
+// PR c++/12515
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+template<int> void foo() { 0 ?: 0; }