aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2018-05-21 14:50:06 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2018-05-21 14:50:06 +0000
commit8b55e70d2f62c12ce7bc3d3aecf795e7a3e001f8 (patch)
tree17f41073b895892b4f7b9b1d8dca80b622adae42 /gcc
parent66c0fa2cc9a2dbe62db5bed4fe5310d2e5912baf (diff)
downloadgcc-8b55e70d2f62c12ce7bc3d3aecf795e7a3e001f8.zip
gcc-8b55e70d2f62c12ce7bc3d3aecf795e7a3e001f8.tar.gz
gcc-8b55e70d2f62c12ce7bc3d3aecf795e7a3e001f8.tar.bz2
[Ada] Extend legality of Scalar_Storage_Order to formal types
This patch extends the legality of the GNAT attribute Scalar_Storage_Order, to apply to formal private types. Previously this extension applied only in GNAT_Mode, to support instantiations of Ada.Sequential_IO, but it is more generally useful. The following must compile quietly: ---- with Memory_View_Generic; procedure Main is type T is array (1..10) of integer; package OK is new Memory_View_Generic (T); type T2 is new Long_Float; package Wrong is new Memory_View_Generic (T2); begin null; end; ---- with System; generic type Source_Type is private; package Memory_View_Generic is -- various declarations ... SSO : System.Bit_Order := Source_Type'Scalar_Storage_Order; end Memory_View_Generic; 2018-05-21 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * sem_attr.adb (Analyze_Attribute, case Scalar_Storage_Order): The attribute reference is legal within a generic unit when the prefix is a formal private type. From-SVN: r260444
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/sem_attr.adb18
2 files changed, 18 insertions, 6 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index e729f18..8233aa4 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,9 @@
+2018-04-04 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_attr.adb (Analyze_Attribute, case Scalar_Storage_Order): The
+ attribute reference is legal within a generic unit when the prefix is a
+ formal private type.
+
2018-04-04 Hristian Kirtchev <kirtchev@adacore.com>
* exp_ch7.adb (Establish_Transient_Scope): Code cleanup. Do not
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index f3824a8bb..9cc3055 100644
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -5709,11 +5709,15 @@ package body Sem_Attr is
if not (Is_Record_Type (P_Type) or else Is_Array_Type (P_Type)) then
- -- In GNAT mode, the attribute applies to generic types as well
- -- as composite types, and for non-composite types always returns
- -- the default bit order for the target.
-
- if not (GNAT_Mode and then Is_Generic_Type (P_Type))
+ -- The attribute applies to generic private types (in which case
+ -- the legality rule is applied in the instance) as well as to
+ -- composite types. For noncomposite types it always returns the
+ -- default bit order for the target.
+ -- Allowing formal private types was originally introduced in
+ -- GNAT_Mode only, to compile instances of Sequential_IO, but
+ -- users find it more generally useful in generic units.
+
+ if not (Is_Generic_Type (P_Type) and then Is_Private_Type (P_Type))
and then not In_Instance
then
Error_Attr_P
@@ -11074,7 +11078,7 @@ package body Sem_Attr is
-- The context may be a constrained access type (however ill-
-- advised such subtypes might be) so in order to generate a
- -- constraint check when needed set the type of the attribute
+ -- constraint check we need to set the type of the attribute
-- reference to the base type of the context.
Set_Etype (N, Btyp);
@@ -11837,6 +11841,8 @@ package body Sem_Attr is
if Attr_Id = Attribute_Elaborated then
null;
+ -- Should this be restricted to Expander_Active???
+
else
Freeze_Expression (P);
end if;