{"id":833475,"url":"http://patchwork.ozlabs.org/api/1.2/patches/833475/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/39398177-ddf0-51de-78d1-7129062ab448@acm.org/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.2/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<39398177-ddf0-51de-78d1-7129062ab448@acm.org>","list_archive_url":null,"date":"2017-11-02T18:24:21","name":"[PR,c++/82710] false positive paren warning","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"0acf0694b18bb3701cf73b7949424e19f8b5b696","submitter":{"id":9970,"url":"http://patchwork.ozlabs.org/api/1.2/people/9970/?format=json","name":"Nathan Sidwell","email":"nathan@acm.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/39398177-ddf0-51de-78d1-7129062ab448@acm.org/mbox/","series":[{"id":11561,"url":"http://patchwork.ozlabs.org/api/1.2/series/11561/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=11561","date":"2017-11-02T18:24:21","name":"[PR,c++/82710] false positive paren warning","version":1,"mbox":"http://patchwork.ozlabs.org/series/11561/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/833475/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/833475/checks/","tags":{},"related":[],"headers":{"Return-Path":"<gcc-patches-return-465776-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-465776-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"KZOIazyz\"; dkim-atps=neutral","sourceware.org; auth=none"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3ySYQq57FVz9sNd\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  3 Nov 2017 05:24:50 +1100 (AEDT)","(qmail 75927 invoked by alias); 2 Nov 2017 18:24:39 -0000","(qmail 41995 invoked by uid 89); 2 Nov 2017 18:24:27 -0000","from mail-yw0-f171.google.com (HELO mail-yw0-f171.google.com)\n\t(209.85.161.171) by sourceware.org\n\t(qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tThu, 02 Nov 2017 18:24:25 +0000","by mail-yw0-f171.google.com with SMTP id k11so401216ywh.1 for\n\t<gcc-patches@gcc.gnu.org>; Thu, 02 Nov 2017 11:24:25 -0700 (PDT)","from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254?\n\t([2620:10d:c091:200::4fa5]) by smtp.googlemail.com with\n\tESMTPSA id y11sm1672766ywc.70.2017.11.02.11.24.22\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256\n\tbits=128/128); Thu, 02 Nov 2017 11:24:22 -0700 (PDT)"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:to\n\t:from:subject:message-id:date:mime-version:content-type; q=dns;\n\ts=default; b=tmer5RKUjYcYt2HvqOdeJjBzKjkcFxO5/fzJ0bb3GDDaMJxbp3\n\tUMoC4wXPUgRR2jLHlcwdXmTJIS7F+py46JOXgrVAQl5jWp0b1DCHH1rKLoG81UL+\n\tL8900ofGl2W4BdD7XE6vS56MnUjd4CpMASy+w25U34d5S4U/4sQL8/t4c=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:to\n\t:from:subject:message-id:date:mime-version:content-type; s=\n\tdefault; bh=Cp6dHeKeBXg0CXAX+Exp3cpgfKk=; b=KZOIazyzUMSJd5VUTG0v\n\tQ+wZkpdeuCvNFgvfItw9DditN+AKRhCBL0pK0+cO+2d2AqQAHTKlUso/TXLOAlGR\n\turtGvXFYjzvSpsgFn19A6DFIedBvzsbD4BGSTT5H6exJ+uU0vtd7I5Xiiw/MgmrQ\n\tnZvLr5qqZp4OFnBOsjW/RiM=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-10.6 required=5.0 tests=BAYES_00,\n\tFREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS,\n\tRCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM,\n\tSPF_PASS autolearn=ham version=3.3.2 spammy=friend","X-HELO":"mail-yw0-f171.google.com","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net;\n\ts=20161025;\n\th=x-gm-message-state:sender:to:from:subject:message-id:date\n\t:user-agent:mime-version:content-language;\n\tbh=AWIdmuESIIZCkPoLIYFRZS37HOXhG7GDKDdeeap54yE=;\n\tb=TN6BZrE6r8Iuyc94Yy6PtGhPJdC4DgyTxcE4ZqH5ibeh2VXcwDhc5AC7BI9ckupJ33\n\t/ECgRjFD1WMQIu3WyNaFbpJWPTtpa/CYcUu7Q/nLESVlUVn9ai6K4S/VybYnMRQhie8C\n\tiCragQaiB+Vl3Htn2PLT3NXw5rOLAKxku122Zvc6l4ekdzD3/MMDbHCN2jolmUKONQCL\n\tO0gKaIznJDqOboLiC1UAX0wZkAPnZrTOPUeE0nc4o4fI71W+qo2jCulGy713/tA/DHQm\n\tBe4cxdF7dZKBbMiSGxPxuBdwvfOKOP94zkjnAsbxg8D0vbHJNwLiNjQImvIDi+4Y8z+f\n\tsEWQ==","X-Gm-Message-State":"AJaThX7V8SbD6AbuFGjR7S3QVdfEp9yHOMdBCMY0e+f0kL8nPTe7k4QJ\t8R4vPbNysWO+d+StQHaBXww=","X-Google-Smtp-Source":"ABhQp+SC6g6B81iet9jmPEHDZxttdiumYGltVTkuSm0jxSxG1VYPVuLuzxrTKXguttBxRAgTwvYWpg==","X-Received":"by 10.37.38.206 with SMTP id m197mr347495ybm.45.1509647063281;\n\tThu, 02 Nov 2017 11:24:23 -0700 (PDT)","To":"GCC Patches <gcc-patches@gcc.gnu.org>","From":"Nathan Sidwell <nathan@acm.org>","Subject":"[PR c++/82710] false positive paren warning","Message-ID":"<39398177-ddf0-51de-78d1-7129062ab448@acm.org>","Date":"Thu, 2 Nov 2017 14:24:21 -0400","User-Agent":"Mozilla/5.0 (X11; Linux x86_64;\n\trv:52.0) Gecko/20100101 Thunderbird/52.4.0","MIME-Version":"1.0","Content-Type":"multipart/mixed;\n\tboundary=\"------------29D8D53BCD0797298F29358B\""},"content":"This patch fixes pr82710, were we erroneously warn on something like:\n    friend class_X (::other::name (...));\nthe parens are needed, otherwise the '::other' is taken to be a \nqualified lookup inside the class_X.\n\nUnfortunately, at the point we can check, we've lost information that \n'::' was used.  So I back off when we see a qualified name there.\n\nnathan","diff":"2017-11-02  Nathan Sidwell  <nathan@acm.org>\n\n\tPR c++/82710\n\t* decl.c (grokdeclarator): Don't warn when parens protect a return\n\ttype from a qualified name.\n\n\tPR c++/82710\n\t* g++.dg/warn/pr82710.C: New.\n\nIndex: cp/decl.c\n===================================================================\n--- cp/decl.c\t(revision 254344)\n+++ cp/decl.c\t(working copy)\n@@ -10788,18 +10788,25 @@ grokdeclarator (const cp_declarator *dec\n \t\t\t\t\t    attr_flags);\n \t}\n \n+      inner_declarator = declarator->declarator;\n+\n       /* We don't want to warn in parmeter context because we don't\n \t yet know if the parse will succeed, and this might turn out\n \t to be a constructor call.  */\n       if (decl_context != PARM\n-\t  && declarator->parenthesized != UNKNOWN_LOCATION)\n+\t  && declarator->parenthesized != UNKNOWN_LOCATION\n+\t  /* If the type is a class and the inner name used a global\n+\t     namespace qualifier, we need the parens.  Unfortunately\n+\t     all we can tell is that a qualified name was used.  */\n+\t  && !(CLASS_TYPE_P (type)\n+\t       && inner_declarator\n+\t       && inner_declarator->kind == cdk_id\n+\t       && inner_declarator->u.id.qualifying_scope))\n \twarning_at (declarator->parenthesized, OPT_Wparentheses,\n \t\t    \"unnecessary parentheses in declaration of %qs\", name);\n       if (declarator->kind == cdk_id || declarator->kind == cdk_decomp)\n \tbreak;\n \n-      inner_declarator = declarator->declarator;\n-\n       switch (declarator->kind)\n \t{\n \tcase cdk_array:\nIndex: testsuite/g++.dg/warn/pr82710.C\n===================================================================\n--- testsuite/g++.dg/warn/pr82710.C\t(revision 0)\n+++ testsuite/g++.dg/warn/pr82710.C\t(working copy)\n@@ -0,0 +1,32 @@\n+// { dg-additional-options -Wparentheses }\n+\n+// the MVP warning triggered on a friend decl.  */\n+class X;\n+\n+namespace here \n+{\n+  // these friends\n+  X friendFunc1();\n+  X *friendFunc2 ();\n+  int friendFunc3 ();\n+}\n+\n+namespace nm\n+{\n+  namespace here \n+  {\n+    // Not these friends\n+    void friendFunc1 ();\n+    void friendFunc2 ();\n+    void friendFunc3 ();\n+  }\n+\n+  class TestClass\n+  {\n+    friend X (::here::friendFunc1 ()); // parens are needed\n+    friend X *(::here::friendFunc2 ()); // { dg-warning \"\" }\n+    friend X *::here::friendFunc2 ();\n+    friend int (::here::friendFunc3 ()); // { dg-warning \"\" }\n+  };\n+}\n+\n","prefixes":["PR","c++/82710"]}