{"id":810575,"url":"http://patchwork.ozlabs.org/api/patches/810575/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/20170906125833.GA117502@adacore.com/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/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":"<20170906125833.GA117502@adacore.com>","list_archive_url":null,"date":"2017-09-06T12:58:33","name":"[Ada] Spurious warning in formal package when use clause is present.","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"f31cea86bc3fd1c953aca44d6cff7c0b83f96a72","submitter":{"id":4418,"url":"http://patchwork.ozlabs.org/api/people/4418/?format=json","name":"Arnaud Charlet","email":"charlet@adacore.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/20170906125833.GA117502@adacore.com/mbox/","series":[{"id":1797,"url":"http://patchwork.ozlabs.org/api/series/1797/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=1797","date":"2017-09-06T12:58:33","name":"[Ada] Spurious warning in formal package when use clause is present.","version":1,"mbox":"http://patchwork.ozlabs.org/series/1797/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/810575/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/810575/checks/","tags":{},"related":[],"headers":{"Return-Path":"<gcc-patches-return-461602-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-461602-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=\"BTX+z3cQ\"; 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 3xnNtt0K49z9sBd\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed,  6 Sep 2017 22:58:45 +1000 (AEST)","(qmail 69504 invoked by alias); 6 Sep 2017 12:58:37 -0000","(qmail 69483 invoked by uid 89); 6 Sep 2017 12:58:36 -0000","from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by\n\tsourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tWed, 06 Sep 2017 12:58:35 +0000","from localhost (localhost.localdomain [127.0.0.1])\tby\n\tfiltered-rock.gnat.com (Postfix) with ESMTP id 7C2B556424;\n\tWed,  6 Sep 2017 08:58:33 -0400 (EDT)","from rock.gnat.com ([127.0.0.1])\tby localhost (rock.gnat.com\n\t[127.0.0.1]) (amavisd-new, port 10024)\twith LMTP id\n\t8qT+qqC4WMI7; Wed,  6 Sep 2017 08:58:33 -0400 (EDT)","from tron.gnat.com (tron.gnat.com [205.232.38.10])\tby\n\trock.gnat.com (Postfix) with ESMTP id 69C9556421;\n\tWed,  6 Sep 2017 08:58:33 -0400 (EDT)","by tron.gnat.com (Postfix, from userid 4192)\tid 6612C4AC;\n\tWed,  6 Sep 2017 08:58:33 -0400 (EDT)"],"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:date\n\t:from:to:cc:subject:message-id:mime-version:content-type; q=dns;\n\ts=default; b=WLKK2SuIYVu0R+mpfiGIrcOkfo/g0RAJdlr7v4R22BiRISJFLC\n\t39MRp7bEVK2rPCsn+NGxXPb3lsPZ2QNtyCkzm/mvx8X9gXbjAet9MrL5zmWvg5mm\n\tCfiqQE9CGJAbAu4FQiY1oK0Tv9gA8KJNj21hz6raEV1MFCclVPlCOTFUA=","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:date\n\t:from:to:cc:subject:message-id:mime-version:content-type; s=\n\tdefault; bh=nKalMK6QZaH0gkDNbBTPc1xFYh8=; b=BTX+z3cQgsIhiveLQ3w+\n\t86qSePTFnYU5kdv8m8pLbmn+rTCM9t+vKIX36JU4CbyZwnTWL41OFjZYNFY00uj0\n\tXWI1zKbzxRpd0jsEzux8pLySdUYHcQeoAUeQkrqNeop3LuJIuGnLkdwBSdVOCqju\n\t9EqpIt59m14Wb2G21BaMUBY=","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.4 required=5.0 tests=AWL, BAYES_00,\n\tGIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS,\n\tRCVD_IN_DNSWL_NONE,\n\tSPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2942,\n\t105313","X-HELO":"rock.gnat.com","Date":"Wed, 6 Sep 2017 08:58:33 -0400","From":"Arnaud Charlet <charlet@adacore.com>","To":"gcc-patches@gcc.gnu.org","Cc":"Ed Schonberg <schonberg@adacore.com>","Subject":"[Ada] Spurious warning in formal package when use clause is present.","Message-ID":"<20170906125833.GA117502@adacore.com>","MIME-Version":"1.0","Content-Type":"multipart/mixed; boundary=\"gKMricLos+KVdGMg\"","Content-Disposition":"inline","User-Agent":"Mutt/1.5.23 (2014-03-12)"},"content":"This patch removes a spurious style warning on an operator declared in a\ngeneric package when the package is used as a formal of a generic subprogram,\nand the subprogream body includes a use clause on that package.\n\nThe following must compile quietly:\n\ngcc -c -gnatyO generic_test.adb\n\n---\nwith Generic_2;\nprocedure Generic_Test is\n\n  generic\n    with package P_1 is new Generic_2 (<>);\n  procedure S_1_G;\n\n  procedure S_1_G is\n      use P_1;\n  begin\n    null;\n  end S_1_G;\n  pragma Unreferenced (S_1_G);\n\nbegin\n  null;\nend Generic_Test;\n---\nwith Dummy;\npragma Unreferenced (Dummy);\n\nwith Generic_1;\n\ngeneric\npackage Generic_2 is\n\n  package P_1 is new Generic_1 (T_1 => Natural);\n\nend Generic_2;\n---\ngeneric\n  type T_1 is limited private;\npackage Generic_1 is\n\nprivate\n\n  type T_2 is\n    record\n      X : T_1;\n    end record;\n\n  function \"=\" (Left, Right : T_2) return Boolean is (True);\n\nend Generic_1;\n--\npackage Dummy is\n\n  generic\n    type T is range <>;\n  package Dummy is\n\n    function Foo (Of_Image : String) return T renames T'Value;\n  end Dummy;\nend Dummy;\n\nTested on x86_64-pc-linux-gnu, committed on trunk\n\n2017-09-06  Ed Schonberg  <schonberg@adacore.com>\n\n\t* sem_aux.adb (Is_Geeric_Formal): Handle properly formal packages.\n\t* sem_ch3.adb (Analyze_Declarations): In a generic subprogram\n\tbody. do not freeze the formals of the generic unit.","diff":"Index: sem_ch3.adb\n===================================================================\n--- sem_ch3.adb\t(revision 251789)\n+++ sem_ch3.adb\t(working copy)\n@@ -2649,9 +2649,27 @@\n                --  in order to perform visibility checks on delayed aspects.\n \n                Adjust_Decl;\n-               Freeze_All (First_Entity (Current_Scope), Decl);\n-               Freeze_From := Last_Entity (Current_Scope);\n \n+               --  If the current scope is a generic subprogram body. skip\n+               --  the generic formal parameters that are not frozen here.\n+\n+               if Is_Subprogram (Current_Scope)\n+                 and then Nkind (Unit_Declaration_Node (Current_Scope))\n+                   = N_Generic_Subprogram_Declaration\n+                 and then Present (First_Entity (Current_Scope))\n+               then\n+                  while Is_Generic_Formal (Freeze_From) loop\n+                     Freeze_From := Next_Entity (Freeze_From);\n+                  end loop;\n+\n+                  Freeze_All (Freeze_From, Decl);\n+                  Freeze_From := Last_Entity (Current_Scope);\n+\n+               else\n+                  Freeze_All (First_Entity (Current_Scope), Decl);\n+                  Freeze_From := Last_Entity (Current_Scope);\n+               end if;\n+\n             --  Current scope is a package specification\n \n             elsif Scope (Current_Scope) /= Standard_Standard\nIndex: sem_aux.adb\n===================================================================\n--- sem_aux.adb\t(revision 251753)\n+++ sem_aux.adb\t(working copy)\n@@ -1053,9 +1053,13 @@\n \n          return\n            Nkind_In (Kind, N_Formal_Object_Declaration,\n-                           N_Formal_Package_Declaration,\n                            N_Formal_Type_Declaration)\n-             or else Is_Formal_Subprogram (E);\n+             or else Is_Formal_Subprogram (E)\n+\n+             or else\n+               (Ekind (E) = E_Package\n+                 and then Nkind (Original_Node (Unit_Declaration_Node (E))) =\n+                    N_Formal_Package_Declaration);\n       end if;\n    end Is_Generic_Formal;\n \n","prefixes":["Ada"]}