From patchwork Mon Nov 25 10:02:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 293872 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0A3FC2C00B1 for ; Mon, 25 Nov 2013 21:03:08 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; q=dns; s=default; b=O1nU0hsujq3/GS3nf MN2faWrzNnTWpJZ61Qcyp7E2Ac681QGIH6PZq17IVLrIQJ5uRKoFmAbzg7rfyxBN 4eR2zk3LhMTTxr9YoiJtWZuzwyarp5GQxTAm50588/b3ATGI2NsU3qU857bdV02K 3UxqYwF9q30PborTrZvPw+611I= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; s=default; bh=j2FdJyEvQw+jvXronDDo4xB 40Tg=; b=SH56BCj+donv5C3Le3FqQIjbZZCpfF40t7/Qeqa6cBJuNhRQeIuFvkH /wtiq6qlmhajyWXqM1Y73MqxiTvbvW/NRuiHEzvp9sf7PNBO1K5SXqb9nAvRfaN6 d20ExUmJeso7gHhWDLBa8dZRAdEm+hdRAAT+huLgAZIgjv1DkBBg= Received: (qmail 18130 invoked by alias); 25 Nov 2013 10:02:58 -0000 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 Received: (qmail 18112 invoked by uid 89); 25 Nov 2013 10:02:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_50, RDNS_NONE, SPF_PASS autolearn=no version=3.3.2 X-HELO: aserp1040.oracle.com Received: from Unknown (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 25 Nov 2013 10:02:56 +0000 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id rAPA2l3T015577 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 25 Nov 2013 10:02:48 GMT Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id rAPA2luQ001450 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 25 Nov 2013 10:02:47 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id rAPA2kjK001438; Mon, 25 Nov 2013 10:02:46 GMT Received: from [192.168.1.4] (/79.45.212.161) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 25 Nov 2013 02:02:46 -0800 Message-ID: <52932044.9080003@oracle.com> Date: Mon, 25 Nov 2013 11:02:44 +0100 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: Jason Merrill , "gcc-patches@gcc.gnu.org" Subject: Re: [C++ Patch] Fixes for duplicate warnings regressions [1/2] References: <527F5F45.5050806@oracle.com> <5290FE1E.50104@redhat.com> In-Reply-To: <5290FE1E.50104@redhat.com> X-IsSubscribed: yes On 11/23/2013 08:12 PM, Jason Merrill wrote: > On 11/10/2013 05:26 AM, Paolo Carlini wrote: >> this is the issue with -Waddress caused by the fix for c++/56930. I'm >> handling it as already described, that is by adding a bool parameter to >> c_common_truthvalue_conversion. > > Why not handle this by making that warning respect > c_inhibit_evaluation_warnings? Good question, but it doesn't work, in the sense that we can't simply protect the warning itself with "c_inhibit_evaluation_warnings == 0" (per the attached) and bump the global around the second cp_convert, because then we don't warn *at all*. The reason being that with the *first* cp_convert we end up calling c_common_truthvalue_conversion with c_inhibit_evaluation_warnings bumped. The bumping happens in cp_truthvalue_conversion. A mess, yes. At this Stage, if we don't feel like going with something like my last try or something even less straightforward reworking the way we bump c_inhibit_evaluation_warnings in the various circumstances, I'm tempted to go back to my first try: - tree folded_result = cp_convert (type, folded, complain); + tree folded_result + = folded != expr ? cp_convert (type, folded, complain) : result; Would it be safe? I mean, is it at all possible that folded == expr and in fact we should call again cp_convert? Because otherwise it's also a (minor) optimization and radically avoids the problem. Paolo. Index: parser.c =================================================================== --- parser.c (revision 204780) +++ parser.c (working copy) @@ -23378,12 +23378,16 @@ cp_parser_late_parsing_nsdmi (cp_parser *parser, t { tree def; + maybe_begin_member_template_processing (field); + push_unparsed_function_queues (parser); def = cp_parser_late_parse_one_default_arg (parser, field, DECL_INITIAL (field), NULL_TREE); pop_unparsed_function_queues (parser); + maybe_end_member_template_processing (); + DECL_INITIAL (field) = def; } Index: pt.c =================================================================== --- pt.c (revision 204780) +++ pt.c (working copy) @@ -151,7 +151,7 @@ static int for_each_template_parm (tree, tree_fn_t struct pointer_set_t*, bool); static tree expand_template_argument_pack (tree); static tree build_template_parm_index (int, int, int, tree, tree); -static bool inline_needs_template_parms (tree); +static bool inline_needs_template_parms (tree, bool); static void push_inline_template_parms_recursive (tree, int); static tree retrieve_local_specialization (tree); static void register_local_specialization (tree, tree); @@ -377,9 +377,9 @@ template_class_depth (tree type) Returns true if processing DECL needs us to push template parms. */ static bool -inline_needs_template_parms (tree decl) +inline_needs_template_parms (tree decl, bool nsdmi) { - if (! DECL_TEMPLATE_INFO (decl)) + if (!decl || (!nsdmi && ! DECL_TEMPLATE_INFO (decl))) return false; return (TMPL_PARMS_DEPTH (DECL_TEMPLATE_PARMS (most_general_template (decl))) @@ -448,16 +448,23 @@ push_inline_template_parms_recursive (tree parmlis } } -/* Restore the template parameter context for a member template or - a friend template defined in a class definition. */ +/* Restore the template parameter context for a member template, a + friend template defined in a class definition, or a non-template + member of template class. */ void maybe_begin_member_template_processing (tree decl) { tree parms; int levels = 0; + bool nsdmi = TREE_CODE (decl) == FIELD_DECL; - if (inline_needs_template_parms (decl)) + if (nsdmi) + decl = (CLASSTYPE_TEMPLATE_INFO (DECL_CONTEXT (decl)) + ? TREE_TYPE (CLASSTYPE_TEMPLATE_INFO (DECL_CONTEXT (decl))) + : NULL_TREE); + + if (inline_needs_template_parms (decl, nsdmi)) { parms = DECL_TEMPLATE_PARMS (most_general_template (decl)); levels = TMPL_PARMS_DEPTH (parms) - processing_template_decl;