]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/34270 (ICE applying __decltype to ternary expression)
authorJakub Jelinek <jakub@gcc.gnu.org>
Thu, 29 Nov 2007 21:06:18 +0000 (22:06 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 29 Nov 2007 21:06:18 +0000 (22:06 +0100)
PR c++/34270
* tree.c (lvalue_p_1) <case COND_EXPR>: Handle x ?: y
in templates.
* typeck.c (is_bitfield_expr_with_lowered_type) <case COND_EXPR>:
Likewise.

* g++.dg/template/cond7.C: New test.

From-SVN: r130520

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/cond7.C [new file with mode: 0644]

index 3f7f9dc1fe9f2814b90958c43bd7a67ebb26d86d..5ff2fa330db38a4debd0b8ef8cffac0112d3ac84 100644 (file)
@@ -1,5 +1,11 @@
 2007-11-29  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/34270
+       * tree.c (lvalue_p_1) <case COND_EXPR>: Handle x ?: y
+       in templates.
+       * typeck.c (is_bitfield_expr_with_lowered_type) <case COND_EXPR>:
+       Likewise.
+
        PR c++/34267
        PR c++/34268
        * parser.c (cp_parser_decltype): Don't call finish_id_expression
@@ -25,7 +31,7 @@
 
 2007-11-25  Richard Guenther  <rguenther@suse.de>
 
-       decl.c (poplevel): Use BLOCK_CHAIN.
+       decl.c (poplevel): Use BLOCK_CHAIN.
 
 2007-11-24  Ollie Wild  <aaw@google.com>
 
index 6ae05686614c4d20f0ea826fab1f848674165a1f..c885d0888780cd54103dfc23d992e50524f2bedf 100644 (file)
@@ -160,7 +160,9 @@ lvalue_p_1 (const_tree ref,
       break;
 
     case COND_EXPR:
-      op1_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 1),
+      op1_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 1)
+                                   ? TREE_OPERAND (ref, 1)
+                                   : TREE_OPERAND (ref, 0),
                                    treat_class_rvalues_as_lvalues);
       op2_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 2),
                                    treat_class_rvalues_as_lvalues);
index da46bb35cac26fb115c75166a9a7067cf30881a3..c43eb793584121dc3e3ccd6022eb886ae8fd8173 100644 (file)
@@ -1419,7 +1419,9 @@ is_bitfield_expr_with_lowered_type (const_tree exp)
   switch (TREE_CODE (exp))
     {
     case COND_EXPR:
-      if (!is_bitfield_expr_with_lowered_type (TREE_OPERAND (exp, 1)))
+      if (!is_bitfield_expr_with_lowered_type (TREE_OPERAND (exp, 1)
+                                              ? TREE_OPERAND (exp, 1)
+                                              : TREE_OPERAND (exp, 0)))
        return NULL_TREE;
       return is_bitfield_expr_with_lowered_type (TREE_OPERAND (exp, 2));
 
index c04a77fb1946629c8b781352089ac295c48440a0..1a40211687223374228e3a5cf0933463f4f4ecb5 100644 (file)
@@ -1,5 +1,8 @@
 2007-11-29  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/34270
+       * g++.dg/template/cond7.C: New test.
+
        PR c++/34267
        PR c++/34268
        * g++.dg/cpp0x/decltype7.C: New test.
diff --git a/gcc/testsuite/g++.dg/template/cond7.C b/gcc/testsuite/g++.dg/template/cond7.C
new file mode 100644 (file)
index 0000000..ce1c77e
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/34270
+// { dg-do compile }
+// { dg-options "" }
+
+void foo ()
+{
+  __typeof__ (0 ?: 0) x;
+  __decltype (0 ?: 0) y;
+}
+
+template<int> void bar ()
+{
+  __typeof__ (0 ?: 0) x;
+  __decltype (0 ?: 0) y;
+}
This page took 0.1492 seconds and 5 git commands to generate.