From bfb1147ca896f985a2268b7b6a0ba4b36394f8cc Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Wed, 14 Nov 2018 11:41:53 +0000 Subject: [PATCH] [Ada] Fix assertion failure on pragma Compile_Time_Error in generic unit There is no point in validating 'Alignment or 'Size of an entity declared in a generic unit after the back-end has been run, since such an entity is not passed to the back-end, and this can even lead to an assertion failure. 2018-11-14 Eric Botcazou gcc/ada/ * sem_prag.adb (Process_Compile_Time_Warning_Or_Error): Don't register a compile-time warning or error for 'Alignment or 'Size of an entity declared in a generic unit. gcc/testsuite/ * gnat.dg/compile_time_error1.adb, gnat.dg/compile_time_error1.ads, gnat.dg/compile_time_error1_pkg.ads: New testcase. From-SVN: r266127 --- gcc/ada/ChangeLog | 6 ++++++ gcc/ada/sem_prag.adb | 1 + gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gnat.dg/compile_time_error1.adb | 7 +++++++ gcc/testsuite/gnat.dg/compile_time_error1.ads | 13 +++++++++++++ gcc/testsuite/gnat.dg/compile_time_error1_pkg.ads | 11 +++++++++++ 6 files changed, 44 insertions(+) create mode 100644 gcc/testsuite/gnat.dg/compile_time_error1.adb create mode 100644 gcc/testsuite/gnat.dg/compile_time_error1.ads create mode 100644 gcc/testsuite/gnat.dg/compile_time_error1_pkg.ads diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index d4dcd8c41d6..82329ac9a23 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2018-11-14 Eric Botcazou + + * sem_prag.adb (Process_Compile_Time_Warning_Or_Error): Don't + register a compile-time warning or error for 'Alignment or 'Size + of an entity declared in a generic unit. + 2018-11-14 Justin Squirek * sem_ch8.adb (Use_One_Package): Add test for out-of-scope diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index a96d148ecbb..cda8629de68 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -7545,6 +7545,7 @@ package body Sem_Prag is begin if Nkind (N) = N_Attribute_Reference and then Is_Entity_Name (Prefix (N)) + and then not Is_Generic_Unit (Scope (Entity (Prefix (N)))) then declare Attr_Id : constant Attribute_Id := diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c4d7657d7d1..00ad237ac25 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-11-14 Eric Botcazou + + * gnat.dg/compile_time_error1.adb, + gnat.dg/compile_time_error1.ads, + gnat.dg/compile_time_error1_pkg.ads: New testcase. + 2018-11-14 Justin Squirek * gnat.dg/generic_pkg.adb: New testcase. diff --git a/gcc/testsuite/gnat.dg/compile_time_error1.adb b/gcc/testsuite/gnat.dg/compile_time_error1.adb new file mode 100644 index 00000000000..db55f587a2f --- /dev/null +++ b/gcc/testsuite/gnat.dg/compile_time_error1.adb @@ -0,0 +1,7 @@ +-- { dg-do compile } + +package body Compile_Time_Error1 is + + procedure Dummy is null; + +end Compile_Time_Error1; diff --git a/gcc/testsuite/gnat.dg/compile_time_error1.ads b/gcc/testsuite/gnat.dg/compile_time_error1.ads new file mode 100644 index 00000000000..f4f83338b2f --- /dev/null +++ b/gcc/testsuite/gnat.dg/compile_time_error1.ads @@ -0,0 +1,13 @@ +with Compile_Time_Error1_Pkg; + +package Compile_Time_Error1 is + + type Rec is record + I : Integer; + end record; + + package Inst is new Compile_Time_Error1_Pkg (Rec); + + procedure Dummy; + +end Compile_Time_Error1; diff --git a/gcc/testsuite/gnat.dg/compile_time_error1_pkg.ads b/gcc/testsuite/gnat.dg/compile_time_error1_pkg.ads new file mode 100644 index 00000000000..92238577246 --- /dev/null +++ b/gcc/testsuite/gnat.dg/compile_time_error1_pkg.ads @@ -0,0 +1,11 @@ +generic + + type T is private; + +package Compile_Time_Error1_Pkg is + + pragma Compile_Time_Error (T'Size not in 8 | 16 | 32, "type too large"); + + Data : T; + +end Compile_Time_Error1_Pkg; -- 2.30.2