aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2020-04-23 19:33:47 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2020-06-18 05:08:32 -0400
commit3874e79d94ef6b8adb99373f2780847633021d16 (patch)
treedf0056c4bfd21a4e64693cd2a76579ec9614c882
parent13175003d4aecbb1cb8f6e5707c22d318bd0f2a0 (diff)
downloadgcc-3874e79d94ef6b8adb99373f2780847633021d16.zip
gcc-3874e79d94ef6b8adb99373f2780847633021d16.tar.gz
gcc-3874e79d94ef6b8adb99373f2780847633021d16.tar.bz2
[Ada] Small cleanup in the attribute code of the expander
2020-06-18 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * exp_attr.adb (Analyze_Attribute) <Asm_{In,Out}put>: Alphabetize. <Component_Size>: Add check for universal integer attribute. <Aft>, <Bit_Order>, <Definite>, <Max_Alignment_For_Allocation>, <Scalar_Storage_Order>: Raise Program_Error on them. * sem_attr.adb (Eval_Attribute) <Component_Size>: Add comment on the packed array case.
-rw-r--r--gcc/ada/exp_attr.adb63
-rw-r--r--gcc/ada/sem_attr.adb5
2 files changed, 34 insertions, 34 deletions
diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb
index 0482ec6..f0f98bb 100644
--- a/gcc/ada/exp_attr.adb
+++ b/gcc/ada/exp_attr.adb
@@ -2531,6 +2531,19 @@ package body Exp_Attr is
end if;
end Alignment;
+ ---------------------------
+ -- Asm_Input, Asm_Output --
+ ---------------------------
+
+ -- The Asm_Input and Asm_Output attributes are not expanded at this
+ -- stage, but will be eliminated in the expansion of the Asm call,
+ -- see Exp_Intr for details. So the back end will never see them.
+
+ when Attribute_Asm_Input
+ | Attribute_Asm_Output
+ =>
+ null;
+
---------
-- Bit --
---------
@@ -2796,6 +2809,15 @@ package body Exp_Attr is
Analyze_And_Resolve (N, Id_Kind);
end Caller;
+ --------------------
+ -- Component_Size --
+ --------------------
+
+ -- Component_Size is handled by the back end
+
+ when Attribute_Component_Size =>
+ Apply_Universal_Integer_Attribute_Checks (N);
+
-------------
-- Compose --
-------------
@@ -2999,7 +3021,7 @@ package body Exp_Attr is
-- Descriptor_Size --
---------------------
- -- Attribute Descriptor_Size is handled by the back end
+ -- Descriptor_Size is handled by the back end
when Attribute_Descriptor_Size =>
Apply_Universal_Integer_Attribute_Checks (N);
@@ -7444,53 +7466,33 @@ package body Exp_Attr is
Rewrite_Attribute_Proc_Call (Pname);
end Write;
- -- Component_Size is handled by the back end, unless the component size
- -- is known at compile time, which is always true in the packed array
- -- case. It is important that the packed array case is handled in the
- -- front end (see Eval_Attribute) since the back end would otherwise get
- -- confused by the equivalent packed array type.
-
- when Attribute_Component_Size =>
- null;
-
-- The following attributes are handled by the back end (except that
-- static cases have already been evaluated during semantic processing,
-- but in any case the back end should not count on this).
- -- The back end also handles the non-class-wide cases of Size
-
- when Attribute_Bit_Order
- | Attribute_Code_Address
- | Attribute_Definite
+ when Attribute_Code_Address
| Attribute_Deref
| Attribute_Null_Parameter
| Attribute_Passed_By_Reference
| Attribute_Pool_Address
- | Attribute_Scalar_Storage_Order
=>
null;
- -- The following attributes are also handled by the back end, but return
- -- a universal integer result, so may need a conversion for checking
- -- that the result is in range.
-
- when Attribute_Aft
- | Attribute_Max_Alignment_For_Allocation
- =>
- Apply_Universal_Integer_Attribute_Checks (N);
-
-- The following attributes should not appear at this stage, since they
-- have already been handled by the analyzer (and properly rewritten
-- with corresponding values or entities to represent the right values)
when Attribute_Abort_Signal
| Attribute_Address_Size
+ | Attribute_Aft
| Attribute_Atomic_Always_Lock_Free
| Attribute_Base
+ | Attribute_Bit_Order
| Attribute_Class
| Attribute_Compiler_Version
| Attribute_Default_Bit_Order
| Attribute_Default_Scalar_Storage_Order
+ | Attribute_Definite
| Attribute_Delta
| Attribute_Denorm
| Attribute_Digits
@@ -7512,6 +7514,7 @@ package body Exp_Attr is
| Attribute_Machine_Overflows
| Attribute_Machine_Radix
| Attribute_Machine_Rounds
+ | Attribute_Max_Alignment_For_Allocation
| Attribute_Maximum_Alignment
| Attribute_Model_Emin
| Attribute_Model_Epsilon
@@ -7526,6 +7529,7 @@ package body Exp_Attr is
| Attribute_Safe_Large
| Attribute_Safe_Last
| Attribute_Safe_Small
+ | Attribute_Scalar_Storage_Order
| Attribute_Scale
| Attribute_Signed_Zeros
| Attribute_Small
@@ -7541,15 +7545,6 @@ package body Exp_Attr is
| Attribute_Word_Size
=>
raise Program_Error;
-
- -- The Asm_Input and Asm_Output attributes are not expanded at this
- -- stage, but will be eliminated in the expansion of the Asm call, see
- -- Exp_Intr for details. So the back end will never see these either.
-
- when Attribute_Asm_Input
- | Attribute_Asm_Output
- =>
- null;
end case;
-- Note: as mentioned earlier, individual sections of the above case
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index 8045193..bf45fb8 100644
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -8530,6 +8530,11 @@ package body Sem_Attr is
-- Component_Size --
--------------------
+ -- Fold Component_Size if it is known at compile time, which is always
+ -- true in the packed array case. It is important that the packed array
+ -- case is handled here since the back end would otherwise get confused
+ -- by the equivalent packed array type.
+
when Attribute_Component_Size =>
if Known_Static_Component_Size (P_Type) then
Fold_Uint (N, Component_Size (P_Type), Static);