[Ada] Checks on alignment with address clauses

Submitted by Arnaud Charlet on June 14, 2010, 8:27 a.m.

Details

Message ID 20100614082733.GA11436@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet June 14, 2010, 8:27 a.m.
Address clauses are checked to verify that they are constistent with the
alignment of the object, after the code generator has established the
required alignment. This check must not be performed on objects of a
generic type, given that the code generator does not see these types and
front-end information is irrelevant for this test.

From code reading, no current example of spurious warnings.

Tested on x86_64-pc-linux-gnu, committed on trunk

2010-06-14  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch13.adb (Analyze_Attribute_Definition_Clause, case Address): Do
	not insert address clause in table for later validation if type of
	entity is generic, to prevent possible spurious errors.

Comments

Duncan Sands June 14, 2010, 9:23 a.m.
Hi Arnaud,

> @@ -1026,13 +1026,19 @@ package body Sem_Ch13 is
>                    --  check till after code generation to take full advantage
>                    --  of the annotation done by the back end. This entry is
>                    --  only made if the address clause comes from source.
> +                  --  If the entity has a generic type, the check will be
> +                  --  performed in the instance if the actual type justfies it,

justfies -> justifies

> +                  --  and we do not insert the clause in the table to prevent
> +                  --  spurious warnings.

Perhaps these last lines should be a new sentence
  "We do not insert the clause in the table to prevent spurious warnings"
and personally I think
  "To prevent spurious warnings, we do not insert the clause in the table"
would be less ambiguous (I found it unclear on first reading).

Ciao,

Duncan.

Patch hide | download patch | download mbox

Index: sem_ch13.adb
===================================================================
--- sem_ch13.adb	(revision 160705)
+++ sem_ch13.adb	(working copy)
@@ -1026,13 +1026,19 @@  package body Sem_Ch13 is
                   --  check till after code generation to take full advantage
                   --  of the annotation done by the back end. This entry is
                   --  only made if the address clause comes from source.
+                  --  If the entity has a generic type, the check will be
+                  --  performed in the instance if the actual type justfies it,
+                  --  and we do not insert the clause in the table to prevent
+                  --  spurious warnings.
 
                   if Address_Clause_Overlay_Warnings
                     and then Comes_From_Source (N)
                     and then Present (O_Ent)
                     and then Is_Object (O_Ent)
                   then
-                     Address_Clause_Checks.Append ((N, U_Ent, O_Ent, Off));
+                     if not Is_Generic_Type (Etype (U_Ent)) then
+                        Address_Clause_Checks.Append ((N, U_Ent, O_Ent, Off));
+                     end if;
 
                      --  If variable overlays a constant view, and we are
                      --  warning on overlays, then mark the variable as