summaryrefslogtreecommitdiff
path: root/gcc/ada/layout.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2013-01-03 10:09:24 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2013-01-03 10:09:24 +0000
commit509f74d31934c8f3552c05194282a520cb7cd41a (patch)
treea2e0ef3632b87fd658f62f0b7ae5acf9f0d287ac /gcc/ada/layout.adb
parentb3c5d8818a5317b6b6001bb7ebe5fa86662f2217 (diff)
downloadgcc-509f74d31934c8f3552c05194282a520cb7cd41a.tar.gz
2013-01-03 Robert Dewar <dewar@adacore.com>
* exp_intr.adb: Minor reformatting. 2013-01-03 Robert Dewar <dewar@adacore.com> * einfo.adb: Minor reformatting. 2013-01-03 Pascal Obry <obry@adacore.com> * adaint.c, adaint.h (__gnat_get_module_name): Removed. (__gnat_is_module_name_supported): Removed. * s-win32.ads: Add some needed definitions. * g-trasym.ads: Update comments. 2013-01-03 Robert Dewar <dewar@adacore.com> * layout.adb (Set_Composite_Alignment): Fix problems of interactions with Optimize_Alignment set to Space. 2013-01-03 Thomas Quinot <quinot@adacore.com> * exp_disp.adb: Minor reformatting. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@194842 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/layout.adb')
-rw-r--r--gcc/ada/layout.adb53
1 files changed, 47 insertions, 6 deletions
diff --git a/gcc/ada/layout.adb b/gcc/ada/layout.adb
index 3ac620ca4ca..55fe37812ce 100644
--- a/gcc/ada/layout.adb
+++ b/gcc/ada/layout.adb
@@ -2873,22 +2873,63 @@ package body Layout is
-- Alignment is not known, see if we can set it, taking into account
-- the setting of the Optimize_Alignment mode.
- -- If Optimize_Alignment is set to Space, then packed records always
- -- have an alignment of 1. But don't do anything for atomic records
- -- since we may need higher alignment for indivisible access.
+ -- If Optimize_Alignment is set to Space, then we try to give packed
+ -- records an aligmment of 1, unless there is some reason we can't.
if Optimize_Alignment_Space (E)
and then Is_Record_Type (E)
and then Is_Packed (E)
- and then not Is_Atomic (E)
then
+ -- No effect for record with atomic components
+
+ if Is_Atomic (E) then
+ Error_Msg_N ("Optimize_Alignment has no effect for &??", E);
+ Error_Msg_N ("\pragma ignored for atomic record??", E);
+ return;
+ end if;
+
+ -- No effect if independent components
+
+ if Has_Independent_Components (E) then
+ Error_Msg_N ("Optimize_Alignment has no effect for &??", E);
+ Error_Msg_N
+ ("\pragma ignored for record with independent components??", E);
+ return;
+ end if;
+
+ -- No effect if any component is atomic or is a by reference type
+
+ declare
+ Ent : Entity_Id;
+ begin
+ Ent := First_Component_Or_Discriminant (E);
+ while Present (Ent) loop
+ if Is_By_Reference_Type (Etype (Ent))
+ or else Is_Atomic (Etype (Ent))
+ or else Is_Atomic (Ent)
+ then
+ Error_Msg_N ("Optimize_Alignment has no effect for &??", E);
+ Error_Msg_N
+ ("\pragma is ignored if atomic components present??", E);
+ return;
+ else
+ Next_Component_Or_Discriminant (Ent);
+ end if;
+ end loop;
+ end;
+
+ -- Optimize_Alignment has no effect on variable length record
+
if not Size_Known_At_Compile_Time (E) then
Error_Msg_N ("Optimize_Alignment has no effect for &??", E);
Error_Msg_N ("\pragma is ignored for variable length record??", E);
- else
- Align := 1;
+ return;
end if;
+ -- All tests passed, we can set alignment to 1
+
+ Align := 1;
+
-- Not a record, or not packed
else