From 662bb4b85ea6f0ccf1871b480554f6197133de1b Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 1 Oct 2014 13:21:08 -0400 Subject: [PATCH] re PR c++/63362 (The c++11 triviality-traits need front-end help) PR c++/63362 * method.c (constructible_expr): Handle value-init of non-class. * parser.c (cp_parser_trait_expr): Allow pack expansion. * pt.c (tsubst_copy_and_build): Handle pack expansion. From-SVN: r215772 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/method.c | 4 +++- gcc/cp/parser.c | 5 +++++ gcc/cp/pt.c | 4 +++- gcc/testsuite/g++.dg/ext/is_trivially_constructible3.C | 8 ++++++++ 5 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ext/is_trivially_constructible3.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9a9fc342569..a3cfa05e23d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2014-10-01 Jason Merrill + PR c++/63362 + * method.c (constructible_expr): Handle value-init of non-class. + * parser.c (cp_parser_trait_expr): Allow pack expansion. + * pt.c (tsubst_copy_and_build): Handle pack expansion. + PR c++/63362 * class.c (type_has_non_user_provided_default_constructor): Rename from type_has_user_provided_default_constructor, reverse sense. diff --git a/gcc/cp/method.c b/gcc/cp/method.c index 9a2bd0f1055..882898658dd 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -1077,7 +1077,9 @@ constructible_expr (tree to, tree from) } else { - if (TREE_CHAIN (from)) + if (from == NULL_TREE) + return build_value_init (to, tf_none); + else if (TREE_CHAIN (from)) return error_mark_node; // too many initializers from = build_stub_object (TREE_VALUE (from)); expr = perform_direct_initialization_if_possible (to, from, diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index e4aaf53fa6c..01b2fadfe01 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -8780,6 +8780,11 @@ cp_parser_trait_expr (cp_parser* parser, enum rid keyword) { cp_lexer_consume_token (parser->lexer); tree elt = cp_parser_type_id (parser); + if (cp_lexer_next_token_is (parser->lexer, CPP_ELLIPSIS)) + { + cp_lexer_consume_token (parser->lexer); + elt = make_pack_expansion (elt); + } if (elt == error_mark_node) return error_mark_node; type2 = tree_cons (NULL_TREE, elt, type2); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 9dd61f3608b..f03e74cd514 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -15487,7 +15487,9 @@ tsubst_copy_and_build (tree t, complain, in_decl); tree type2 = TRAIT_EXPR_TYPE2 (t); - if (type2) + if (type2 && TREE_CODE (type2) == TREE_LIST) + type2 = RECUR (type2); + else if (type2) type2 = tsubst (type2, args, complain, in_decl); RETURN (finish_trait_expr (TRAIT_EXPR_KIND (t), type1, type2)); diff --git a/gcc/testsuite/g++.dg/ext/is_trivially_constructible3.C b/gcc/testsuite/g++.dg/ext/is_trivially_constructible3.C new file mode 100644 index 00000000000..02a678a8ab6 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/is_trivially_constructible3.C @@ -0,0 +1,8 @@ +// { dg-do compile { target c++11 } } + +template void bar() { + static_assert(__is_trivially_constructible(T, Args...), ""); +} + +template void bar(); +template void bar(); -- 2.30.2