From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 65DED3858D32; Tue, 31 Jan 2023 02:13:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 65DED3858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675131217; bh=HQWAzSYvOxR0lyVMnT6zkkULSOR3odPSugSHWpJtEBc=; h=From:To:Subject:Date:From; b=JHAUnBvFc0jM5IddUbnmxcg3UEfPlYUXB3ox7Bi9xAUbnV+xQWxI3hJjgNI7Dseiu DkM1LbDFSqRT6vWAxvXVnWoxK/ETkC0DhJ+19dotizqwiJ+HVB2NcElPTpFl2WPjgb +HRES2tJOPZHJDm4lGmyAZTCHwLb33kcgZzCqNTs= From: "sbelmont700 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug ada/108610] New: Pure library procedures with limited parameters miscategorized Date: Tue, 31 Jan 2023 02:13:35 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ada X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: sbelmont700 at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108610 Bug ID: 108610 Summary: Pure library procedures with limited parameters miscategorized Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ada Assignee: unassigned at gcc dot gnu.org Reporter: sbelmont700 at gmail dot com CC: dkm at gcc dot gnu.org Target Milestone: --- The following (seemingly) legal code is rejected with a categorization erro= r, despite the elaboration pragma on B and apparently not violating any of the requirements of 10.2.1: package A is pragma Pure;=20=20 type T is limited null record; end A; with A; procedure B (x : A.T) is pragma Pure; begin null; end B; with B; package C is pragma Pure; end C; $gnatmake -f c.ads gcc -c c.ads c.ads:1:06: error: cannot depend on "B" (wrong categorization) c.ads:1:06: error: pure unit cannot depend on non-pure unit gnatmake: "c.ads" compilation error Presumably, gnat considers B as impure to implement the exception to the permission in 10.2.1~18/3 (subprograms with limited parameters cannot have their results reused), so this might also apply to parameters that take System.Address, etc, or also in reverse (i.e. pure units incorrectly being allowed to with non-pure units that the compiler has determined can be optimized). The version of GCC was built from the following commit: commit 607f278a3546fe6b91a881318db85d7a0dfdacd9 (HEAD -> master, origin/tru= nk, origin/master, origin/HEAD) Author: GCC Administrator Date: Tue Jan 24 00:17:23 2023 +0000 Daily bump. With the following configuration $gnatmake -v GNATMAKE 13.0.1 20230124 (experimental) Copyright (C) 1992-2023, Free Software Foundation, Inc. try "gnatmake --help" for more information. $gcc -v Using built-in specs. COLLECT_GCC=3Dgcc COLLECT_LTO_WRAPPER=3D/home/sb/src/gcc/bin/libexec/gcc/x86_64-pc-linux-gnu/= 13.0.1/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../src/configure --prefix=3D/home/sb/src/gcc/bin --enable-languages=3Dc,c++,ada --disable-multilib Thread model: posix Supported LTO compression algorithms: zlib gcc version 13.0.1 20230124 (experimental) (GCC)=20 The following patch appears to mitigate the issue (within the Get_Categorization subprogram, only consider the entity as pure if it has b= een explicitly declared Pure) and passed the test suite, but i wouldn't presume= to imply its accuracy.=20 diff --git a/gcc/ada/sem_cat.adb b/gcc/ada/sem_cat.adb index 5398153a35d..ac276eb5443 100644 --- a/gcc/ada/sem_cat.adb +++ b/gcc/ada/sem_cat.adb @@ -160,7 +160,7 @@ package body Sem_Cat is -- Ignore Pure specification if set by pragma Pure_Function - if Is_Pure (E) + if Has_Pragma_Pure (E) and then not (Has_Pragma_Pure_Function (E) and not Has_Pragma_Pure (E)) then Thanks=