From d555b1c77dd2eaf14475a83df44f6c891b5e1d01 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Mon, 19 Jul 2010 10:27:58 +0000 Subject: [PATCH] re PR c++/44969 ([C++0x] std::is_constructible broken for fundamental types.) /cp 2010-07-19 Paolo Carlini PR c++/44969 * typeck.c (build_x_compound_expr_from_list): Add tsubst_flags_t parameter. * cp-tree.h: Adjust declaration. * init.c (perform_member_init): Adjust caller. * decl.c (grok_reference_init, cp_finish_decl): Likewise. * typeck2.c (store_init_value): Likewise. (build_functional_cast): Pass complain argument to build_x_compound_expr_from_list. /testsuite 2010-07-19 Paolo Carlini PR c++/44969 * g++.dg/template/sfinae23.C: New. From-SVN: r162303 --- gcc/cp/ChangeLog | 12 ++++++++++++ gcc/cp/cp-tree.h | 3 ++- gcc/cp/decl.c | 6 ++++-- gcc/cp/init.c | 3 ++- gcc/cp/typeck.c | 12 +++++++----- gcc/cp/typeck2.c | 5 +++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/sfinae23.C | 23 +++++++++++++++++++++++ 8 files changed, 58 insertions(+), 11 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/sfinae23.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 79598d1d3cd..63d24a2ac12 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,15 @@ +2010-07-19 Paolo Carlini + + PR c++/44969 + * typeck.c (build_x_compound_expr_from_list): Add tsubst_flags_t + parameter. + * cp-tree.h: Adjust declaration. + * init.c (perform_member_init): Adjust caller. + * decl.c (grok_reference_init, cp_finish_decl): Likewise. + * typeck2.c (store_init_value): Likewise. + (build_functional_cast): Pass complain argument to + build_x_compound_expr_from_list. + 2010-07-16 Jason Merrill PR c++/32505 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 13d43da7dbe..155db4ce4a8 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -5462,7 +5462,8 @@ extern tree cp_build_unary_op (enum tree_code, tree, int, extern tree unary_complex_lvalue (enum tree_code, tree); extern tree build_x_conditional_expr (tree, tree, tree, tsubst_flags_t); -extern tree build_x_compound_expr_from_list (tree, expr_list_kind); +extern tree build_x_compound_expr_from_list (tree, expr_list_kind, + tsubst_flags_t); extern tree build_x_compound_expr_from_vec (VEC(tree,gc) *, const char *); extern tree build_x_compound_expr (tree, tree, tsubst_flags_t); extern tree build_compound_expr (location_t, tree, tree); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index ddc262b22b6..3aaa20c0ed3 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4462,7 +4462,8 @@ grok_reference_init (tree decl, tree type, tree init, tree *cleanup) } if (TREE_CODE (init) == TREE_LIST) - init = build_x_compound_expr_from_list (init, ELK_INIT); + init = build_x_compound_expr_from_list (init, ELK_INIT, + tf_warning_or_error); if (TREE_CODE (TREE_TYPE (type)) != ARRAY_TYPE && TREE_CODE (TREE_TYPE (init)) == ARRAY_TYPE) @@ -5683,7 +5684,8 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, return; } if (TREE_CODE (init) == TREE_LIST) - init = build_x_compound_expr_from_list (init, ELK_INIT); + init = build_x_compound_expr_from_list (init, ELK_INIT, + tf_warning_or_error); if (describable_type (init)) { type = TREE_TYPE (decl) = do_auto_deduction (type, init, auto_node); diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 5da8191a8f8..d796fd0822c 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -525,7 +525,8 @@ perform_member_init (tree member, tree init) else if (TREE_CODE (init) == TREE_LIST) /* There was an explicit member initialization. Do some work in that case. */ - init = build_x_compound_expr_from_list (init, ELK_MEM_INIT); + init = build_x_compound_expr_from_list (init, ELK_MEM_INIT, + tf_warning_or_error); if (init) finish_expr_stmt (cp_build_modify_expr (decl, INIT_EXPR, init, diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 12e76497df1..484d299f462 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5502,14 +5502,16 @@ build_x_conditional_expr (tree ifexp, tree op1, tree op2, that performs them all and returns the value of the last of them. */ tree -build_x_compound_expr_from_list (tree list, expr_list_kind exp) +build_x_compound_expr_from_list (tree list, expr_list_kind exp, + tsubst_flags_t complain) { tree expr = TREE_VALUE (list); if (TREE_CHAIN (list)) { - switch (exp) - { + if (complain & tf_error) + switch (exp) + { case ELK_INIT: permerror (input_location, "expression list treated as compound " "expression in initializer"); @@ -5524,11 +5526,11 @@ build_x_compound_expr_from_list (tree list, expr_list_kind exp) break; default: gcc_unreachable (); - } + } for (list = TREE_CHAIN (list); list; list = TREE_CHAIN (list)) expr = build_x_compound_expr (expr, TREE_VALUE (list), - tf_warning_or_error); + complain); } return expr; diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index efe7030dabd..ce83d7c40b7 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -737,7 +737,8 @@ store_init_value (tree decl, tree init, int flags) } else /* We get here with code like `int a (2);' */ - init = build_x_compound_expr_from_list (init, ELK_INIT); + init = build_x_compound_expr_from_list (init, ELK_INIT, + tf_warning_or_error); } /* End of special C++ code. */ @@ -1594,7 +1595,7 @@ build_functional_cast (tree exp, tree parms, tsubst_flags_t complain) return cp_convert (type, integer_zero_node); /* This must build a C cast. */ - parms = build_x_compound_expr_from_list (parms, ELK_FUNC_CAST); + parms = build_x_compound_expr_from_list (parms, ELK_FUNC_CAST, complain); return cp_build_c_cast (type, parms, complain); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 100d605e9cc..c898a9eea1b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-07-19 Paolo Carlini + + PR c++/44969 + * g++.dg/template/sfinae23.C: New. + 2010-07-19 Rainer Orth * lib/target-supports.exp (check_sse_os_support_available): New diff --git a/gcc/testsuite/g++.dg/template/sfinae23.C b/gcc/testsuite/g++.dg/template/sfinae23.C new file mode 100644 index 00000000000..9e0197a7050 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/sfinae23.C @@ -0,0 +1,23 @@ +// PR c++/44969 +// { dg-options "-std=c++0x" } + +template + class mini_is_constructible + { + typedef char one; + typedef struct { char arr[2]; } two; + + template + static decltype(Tp1(Args1()...), one()) + test(int); + + template + static two test(...); + + public: + static const bool value = sizeof(test(0)) == 1; + }; + +class A { }; + +int Test[mini_is_constructible::value ? -1 : 1]; -- 2.30.2