]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Check intrinsic subprograms specified by an aspect
authorPiotr Trojanek <trojanek@adacore.com>
Wed, 20 May 2026 14:53:34 +0000 (16:53 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 4 Jun 2026 08:42:24 +0000 (10:42 +0200)
We only checked intrinsic subprograms specified by pragmas that come from
source, but this missed subprograms specified by an aspect (because its
internally generated corresponding pragma doesn't come from source).

gcc/ada/ChangeLog:

* sem_intr.adb (Check_Intrinsic_Subprogram): Recognize pragmas that
do not come from source because they come from aspect specification.

gcc/ada/sem_intr.adb

index 0657ec7e725fd3cda553ddcb7e1b90791153f7f0..7614e8364d376d2aa02a3ef043286aaf8397dafc 100644 (file)
@@ -309,6 +309,16 @@ package body Sem_Intr is
       Nam  : Name_Id;
 
    begin
+      --  Intrinsic subprograms will be accompanied by a pragma, either a one
+      --  that comes from source, or a one that comes from translating the
+      --  corresponding aspect. Generic intrinsics subprograms don't have such
+      --  a pragma; only their instances have.
+
+      pragma Assert
+        (if Is_Subprogram (E)
+         then Present (Import_Pragma (E))
+         else Is_Generic_Subprogram (E));
+
       if Present (Spec)
         and then Present (Generic_Parent (Spec))
       then
@@ -341,7 +351,9 @@ package body Sem_Intr is
       --  they are doing, and do not write or generate junk use of intrinsic.
 
       elsif not Comes_From_Source (E)
-        or else not Comes_From_Source (N)
+        or else (Is_Subprogram (E)
+                   and then not Comes_From_Source (N)
+                   and then not From_Aspect_Specification (Import_Pragma (E)))
         or else In_Predefined_Unit (N)
       then
          null;