PR c++/63362
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 1 Oct 2014 17:21:08 +0000 (17:21 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 1 Oct 2014 17:21:08 +0000 (17:21 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@215772 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/method.c
gcc/cp/parser.c
gcc/cp/pt.c
gcc/testsuite/g++.dg/ext/is_trivially_constructible3.C [new file with mode: 0644]

index 9a9fc34..a3cfa05 100644 (file)
@@ -1,6 +1,11 @@
 2014-10-01  Jason Merrill  <jason@redhat.com>
 
        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.
        (default_init_uninitialized_part, explain_non_literal_class): Adjust.
index 9a2bd0f..8828986 100644 (file)
@@ -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,
index e4aaf53..01b2fad 100644 (file)
@@ -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);
index 9dd61f3..f03e74c 100644 (file)
@@ -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 (file)
index 0000000..02a678a
--- /dev/null
@@ -0,0 +1,8 @@
+// { dg-do compile { target c++11 } }
+
+template <class T, class... Args> void bar() {
+  static_assert(__is_trivially_constructible(T, Args...), "");
+}
+
+template void bar<int>();
+template void bar<int,int>();