From patchwork Mon Jul 19 10:29:24 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 59190 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id B40AAB6EF7 for ; Mon, 19 Jul 2010 20:29:41 +1000 (EST) Received: (qmail 6760 invoked by alias); 19 Jul 2010 10:29:38 -0000 Received: (qmail 6750 invoked by uid 22791); 19 Jul 2010 10:29:37 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from vsmtp4.tin.it (HELO vsmtp4.tin.it) (212.216.176.224) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 19 Jul 2010 10:29:28 +0000 Received: from [192.168.0.4] (79.43.214.249) by vsmtp4.tin.it (8.5.113) id 4BCE3CBE07A6D9DF for gcc-patches@gcc.gnu.org; Mon, 19 Jul 2010 12:29:25 +0200 Message-ID: <4C442904.2040806@oracle.com> Date: Mon, 19 Jul 2010 12:29:24 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100520 SUSE/3.0.5 Thunderbird/3.0.5 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" Subject: [C++, committed] PR 44969 (first half) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, tested x86_64-linux, approved by Jason in the audit-trail, committed to mainline. Paolo. //////////////////// /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. Index: testsuite/g++.dg/template/sfinae23.C =================================================================== --- testsuite/g++.dg/template/sfinae23.C (revision 0) +++ testsuite/g++.dg/template/sfinae23.C (revision 0) @@ -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]; Index: cp/typeck.c =================================================================== --- cp/typeck.c (revision 162298) +++ cp/typeck.c (working copy) @@ -5502,14 +5502,16 @@ build_x_conditional_expr (tree ifexp, tree op1, tr 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 @@ tree 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; Index: cp/init.c =================================================================== --- cp/init.c (revision 162298) +++ cp/init.c (working copy) @@ -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, Index: cp/decl.c =================================================================== --- cp/decl.c (revision 162298) +++ cp/decl.c (working copy) @@ -4462,7 +4462,8 @@ grok_reference_init (tree decl, tree type, tree in } 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_co 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); Index: cp/typeck2.c =================================================================== --- cp/typeck2.c (revision 162298) +++ cp/typeck2.c (working copy) @@ -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, tsubs 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); } Index: cp/cp-tree.h =================================================================== --- cp/cp-tree.h (revision 162298) +++ cp/cp-tree.h (working copy) @@ -5462,7 +5462,8 @@ extern tree cp_build_unary_op (e 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);