From 42924ed71f51fd6c33483ca202fc5a1ccff9b770 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 29 Nov 2007 22:06:18 +0100 Subject: [PATCH] re PR c++/34270 (ICE applying __decltype to ternary expression) PR c++/34270 * tree.c (lvalue_p_1) : Handle x ?: y in templates. * typeck.c (is_bitfield_expr_with_lowered_type) : Likewise. * g++.dg/template/cond7.C: New test. From-SVN: r130520 --- gcc/cp/ChangeLog | 8 +++++++- gcc/cp/tree.c | 4 +++- gcc/cp/typeck.c | 4 +++- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/template/cond7.C | 15 +++++++++++++++ 5 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/cond7.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3f7f9dc1fe9..5ff2fa330db 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,11 @@ 2007-11-29 Jakub Jelinek + PR c++/34270 + * tree.c (lvalue_p_1) : Handle x ?: y + in templates. + * typeck.c (is_bitfield_expr_with_lowered_type) : + 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 - decl.c (poplevel): Use BLOCK_CHAIN. + * decl.c (poplevel): Use BLOCK_CHAIN. 2007-11-24 Ollie Wild diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 6ae05686614..c885d088878 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -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); diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index da46bb35cac..c43eb793584 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -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)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c04a77fb194..1a402116872 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2007-11-29 Jakub Jelinek + 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 index 00000000000..ce1c77e593b --- /dev/null +++ b/gcc/testsuite/g++.dg/template/cond7.C @@ -0,0 +1,15 @@ +// PR c++/34270 +// { dg-do compile } +// { dg-options "" } + +void foo () +{ + __typeof__ (0 ?: 0) x; + __decltype (0 ?: 0) y; +} + +template void bar () +{ + __typeof__ (0 ?: 0) x; + __decltype (0 ?: 0) y; +}