aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/exp_attr.adb
diff options
context:
space:
mode:
authorRobert Dewar <dewar@adacore.com>2007-12-19 17:23:09 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2007-12-19 17:23:09 +0100
commitcf284c756a3e6bb36b74c61c5791f28724ed744b (patch)
tree75c582a077c9d81d589519d70a412888458375d7 /gcc/ada/exp_attr.adb
parent4a76b687c424b460021ad90e7ade96e66e4c0bf1 (diff)
downloadgcc-cf284c756a3e6bb36b74c61c5791f28724ed744b.zip
gcc-cf284c756a3e6bb36b74c61c5791f28724ed744b.tar.gz
gcc-cf284c756a3e6bb36b74c61c5791f28724ed744b.tar.bz2
exp_attr.adb (Expand_N_Attribute_Reference, case Size): Fix error in handling compile time known size of record or array (case of front...
2007-12-19 Robert Dewar <dewar@adacore.com> * exp_attr.adb (Expand_N_Attribute_Reference, case Size): Fix error in handling compile time known size of record or array (case of front end layout active, e.g. in GNAAMP). From-SVN: r131072
Diffstat (limited to 'gcc/ada/exp_attr.adb')
-rw-r--r--gcc/ada/exp_attr.adb24
1 files changed, 20 insertions, 4 deletions
diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb
index 4baf55e..b7c7d1d 100644
--- a/gcc/ada/exp_attr.adb
+++ b/gcc/ada/exp_attr.adb
@@ -3756,13 +3756,29 @@ package body Exp_Attr is
-- Common processing for record and array component case
if Siz /= No_Uint and then Siz /= 0 then
- Rewrite (N, Make_Integer_Literal (Loc, Siz));
+ declare
+ CS : constant Boolean := Comes_From_Source (N);
- Analyze_And_Resolve (N, Typ);
+ begin
+ Rewrite (N, Make_Integer_Literal (Loc, Siz));
+
+ -- This integer literal is not a static expression. We do not
+ -- call Analyze_And_Resolve here, because this would activate
+ -- the circuit for deciding that a static value was out of
+ -- range, and we don't want that.
- -- The result is not a static expression
+ -- So just manually set the type, mark the expression as non-
+ -- static, and then ensure that the result is checked properly
+ -- if the attribute comes from source (if it was internally
+ -- generated, we never need a constraint check).
- Set_Is_Static_Expression (N, False);
+ Set_Etype (N, Typ);
+ Set_Is_Static_Expression (N, False);
+
+ if CS then
+ Apply_Constraint_Check (N, Typ);
+ end if;
+ end;
end if;
end Size;