re PR c++/34270 (ICE applying __decltype to ternary expression)

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
This commit is contained in:
Jakub Jelinek 2007-11-29 22:06:18 +01:00
parent 7a547b936c
commit 42924ed71f
5 changed files with 31 additions and 3 deletions

View 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>

View 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);

View 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));

View 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.

View File

@ -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;
}