From: Piotr Trojanek <[email protected]>
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.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/sem_intr.adb | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/gcc/ada/sem_intr.adb b/gcc/ada/sem_intr.adb
index 0657ec7e725..7614e8364d3 100644
--- a/gcc/ada/sem_intr.adb
+++ b/gcc/ada/sem_intr.adb
@@ -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;
--
2.53.0