From patchwork Sat Sep 29 00:06:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 187913 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 9D7A22C00BF for ; Sat, 29 Sep 2012 10:07:07 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1349482028; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Message-ID:Date:From:User-Agent:MIME-Version: To:CC:Subject:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=IikwNhTegeowO13oTyDM3DeO/Hk=; b=nOHQ/UWTiq2V5x/ ou/haSmF3tboxDKtLoML9O7zltZzszUOlOeOf7LcyjTOq44cFgDDyJyICJ3zLgvs yRcSCnGu+pu13a46IVQgB7Y2++m/1lCbX6wzldZEXgQUa5mr9JxBYOZ5ERY5Mdfh yGWhCdaJ77k7p+9ANHP4EqiDG3uQ= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=N+WmzmXAxd9GfOKRZhyhZZiURs1DvYKjxD1rfi8rb2ecdOirfufvI7+LOwINFf AhQb2qUAJramhl2sH8XhJvs3vBaMK1VSK9tbOVbNVFPvKXLYtwNtJu15esIbS+oN YWihzoC5hmuq/uiucRN2MUxa78i6klMxByAVmHJGTTDJU=; Received: (qmail 22613 invoked by alias); 29 Sep 2012 00:07:05 -0000 Received: (qmail 22599 invoked by uid 22791); 29 Sep 2012 00:07:02 -0000 X-SWARE-Spam-Status: No, hits=-7.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from rcsinet15.oracle.com (HELO rcsinet15.oracle.com) (148.87.113.117) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 29 Sep 2012 00:06:58 +0000 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q8T06udw013695 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 29 Sep 2012 00:06:57 GMT Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q8T06uwU019457 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 29 Sep 2012 00:06:56 GMT Received: from abhmt107.oracle.com (abhmt107.oracle.com [141.146.116.59]) by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q8T06tOW026900; Fri, 28 Sep 2012 19:06:55 -0500 Received: from [192.168.1.4] (/79.47.193.196) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 28 Sep 2012 17:06:55 -0700 Message-ID: <50663B9D.3050102@oracle.com> Date: Sat, 29 Sep 2012 02:06:53 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120825 Thunderbird/15.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 54738 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, Daniel, while working on the SFINAE-friendly std::result_of, noticed one more SFINAE bug: we weren't propagating complain from tsubst_copy_and_build via build_offset_ref_call_from_tree. Fixed the usual way. Tested x86_64-linux. Thanks, Paolo. /////////////////////////// /cp 2012-09-28 Paolo Carlini PR c++/54738 * decl2.c (build_offset_ref_call_from_tree): Add tsubst_flags_t parameter. * pt.c (tsubst_copy_and_build): Adjust. * parser.c (cp_parser_postfix_expression): Likewise. * cp-tree.h: Adjust declaration. /testsuite 2012-09-28 Paolo Carlini PR c++/54738 * g++.dg/cpp0x/sfinae42.C: New. Index: cp/pt.c =================================================================== --- cp/pt.c (revision 191843) +++ cp/pt.c (working copy) @@ -13783,7 +13783,8 @@ tsubst_copy_and_build (tree t, mark_used (function); if (TREE_CODE (function) == OFFSET_REF) - ret = build_offset_ref_call_from_tree (function, &call_args); + ret = build_offset_ref_call_from_tree (function, &call_args, + complain); else if (TREE_CODE (function) == COMPONENT_REF) { tree instance = TREE_OPERAND (function, 0); Index: cp/parser.c =================================================================== --- cp/parser.c (revision 191843) +++ cp/parser.c (working copy) @@ -5749,7 +5749,8 @@ cp_parser_postfix_expression (cp_parser *parser, b || TREE_CODE (postfix_expression) == MEMBER_REF || TREE_CODE (postfix_expression) == DOTSTAR_EXPR) postfix_expression = (build_offset_ref_call_from_tree - (postfix_expression, &args)); + (postfix_expression, &args, + tf_warning_or_error)); else if (idk == CP_ID_KIND_QUALIFIED) /* A call to a static class member, or a namespace-scope function. */ Index: cp/cp-tree.h =================================================================== --- cp/cp-tree.h (revision 191843) +++ cp/cp-tree.h (working copy) @@ -5149,7 +5149,8 @@ extern void determine_visibility (tree); extern void constrain_class_visibility (tree); extern void import_export_decl (tree); extern tree build_cleanup (tree); -extern tree build_offset_ref_call_from_tree (tree, VEC(tree,gc) **); +extern tree build_offset_ref_call_from_tree (tree, VEC(tree,gc) **, + tsubst_flags_t); extern bool decl_constant_var_p (tree); extern bool decl_maybe_constant_var_p (tree); extern void check_default_args (tree); Index: cp/decl2.c =================================================================== --- cp/decl2.c (revision 191843) +++ cp/decl2.c (working copy) @@ -4087,7 +4087,8 @@ cp_write_global_declarations (void) ARGS. */ tree -build_offset_ref_call_from_tree (tree fn, VEC(tree,gc) **args) +build_offset_ref_call_from_tree (tree fn, VEC(tree,gc) **args, + tsubst_flags_t complain) { tree orig_fn; VEC(tree,gc) *orig_args = NULL; @@ -4115,7 +4116,7 @@ tree if (TREE_CODE (TREE_TYPE (fn)) == METHOD_TYPE) { if (TREE_CODE (fn) == DOTSTAR_EXPR) - object = cp_build_addr_expr (object, tf_warning_or_error); + object = cp_build_addr_expr (object, complain); VEC_safe_insert (tree, gc, *args, 0, object); } /* Now that the arguments are done, transform FN. */ @@ -4130,17 +4131,17 @@ tree void B::g() { (this->*p)(); } */ if (TREE_CODE (fn) == OFFSET_REF) { - tree object_addr = cp_build_addr_expr (object, tf_warning_or_error); + tree object_addr = cp_build_addr_expr (object, complain); fn = TREE_OPERAND (fn, 1); fn = get_member_function_from_ptrfunc (&object_addr, fn, - tf_warning_or_error); + complain); VEC_safe_insert (tree, gc, *args, 0, object_addr); } if (CLASS_TYPE_P (TREE_TYPE (fn))) - expr = build_op_call (fn, args, tf_warning_or_error); + expr = build_op_call (fn, args, complain); else - expr = cp_build_function_call_vec (fn, args, tf_warning_or_error); + expr = cp_build_function_call_vec (fn, args, complain); if (processing_template_decl && expr != error_mark_node) expr = build_min_non_dep_call_vec (expr, orig_fn, orig_args); Index: testsuite/g++.dg/cpp0x/sfinae42.C =================================================================== --- testsuite/g++.dg/cpp0x/sfinae42.C (revision 0) +++ testsuite/g++.dg/cpp0x/sfinae42.C (working copy) @@ -0,0 +1,46 @@ +// PR c++/54738 +// { dg-do compile { target c++11 } } + +template +T&& declval(); + +template +decltype(((*declval()).*declval())(declval()...)) +test1(int); + +template +void test1(...); + +template +decltype((declval().*declval())(declval()...)) +test2(int); + +template +void test2(...); + +struct S {}; + +typedef void (S::*Func)(int) const; +typedef void (S::*Func2)(int); + +typedef decltype(test1(0)) type1a; +typedef decltype(test1(0)) type1b; +typedef decltype(test1(0)) type1c; +typedef decltype(test1(0)) type1d; + +typedef decltype(test2(0)) type2a; +typedef decltype(test2(0)) type2b; +typedef decltype(test2(0)) type2c; +typedef decltype(test2(0)) type2d; + +typedef decltype(test1(0)) type3a; +typedef decltype(test1(0)) type3b; + +typedef decltype(test2(0)) type4a; +typedef decltype(test2(0)) type4b; + +typedef decltype(test1(0)) type5a; +typedef decltype(test1(0)) type5b; + +typedef decltype(test2(0)) type6a; +typedef decltype(test2(0)) type6b;