mirror of git://gcc.gnu.org/git/gcc.git
decl.c (gnat_to_gnu_field): Emit a specialized diagnostic for component size mismatch wrt volatile requirements.
* gcc-interface/decl.c (gnat_to_gnu_field): Emit a specialized diagnostic for component size mismatch wrt volatile requirements. Add a gcc_unreachable() at the end of the checks for size. Split the check on volatile for positions into one check on atomic and a subsequent one on volatile. From-SVN: r194946
This commit is contained in:
parent
a43abae8d3
commit
bd95368b59
|
|
@ -1,3 +1,11 @@
|
||||||
|
2013-01-06 Olivier Hainque <hainque@adacore.com>
|
||||||
|
|
||||||
|
* gcc-interface/decl.c (gnat_to_gnu_field): Emit a specialized
|
||||||
|
diagnostic for component size mismatch wrt volatile requirements.
|
||||||
|
Add a gcc_unreachable() at the end of the checks for size. Split
|
||||||
|
the check on volatile for positions into one check on atomic and
|
||||||
|
a subsequent one on volatile.
|
||||||
|
|
||||||
2013-01-06 Eric Botcazou <ebotcazou@adacore.com>
|
2013-01-06 Eric Botcazou <ebotcazou@adacore.com>
|
||||||
|
|
||||||
* gcc-interface/decl.c (elaborate_entity) <E_Record_Type>: Delete.
|
* gcc-interface/decl.c (elaborate_entity) <E_Record_Type>: Delete.
|
||||||
|
|
|
||||||
|
|
@ -6489,10 +6489,11 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If this field needs strict alignment, check that the record is
|
/* If this field needs strict alignment, check that the record is
|
||||||
sufficiently aligned and that position and size are consistent
|
sufficiently aligned and that position and size are consistent with
|
||||||
with the alignment. But don't do it if we are just annotating
|
the alignment. But don't do it if we are just annotating types and
|
||||||
types and the field's type is tagged, since tagged types aren't
|
the field's type is tagged, since tagged types aren't fully laid out
|
||||||
fully laid out in this mode. */
|
in this mode. Also, note that atomic implies volatile so the inner
|
||||||
|
test sequences ordering is significant here. */
|
||||||
if (needs_strict_alignment
|
if (needs_strict_alignment
|
||||||
&& !(type_annotate_only && Is_Tagged_Type (gnat_field_type)))
|
&& !(type_annotate_only && Is_Tagged_Type (gnat_field_type)))
|
||||||
{
|
{
|
||||||
|
|
@ -6508,6 +6509,12 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed,
|
||||||
Last_Bit (Component_Clause (gnat_field)), gnat_field,
|
Last_Bit (Component_Clause (gnat_field)), gnat_field,
|
||||||
TYPE_SIZE (gnu_field_type));
|
TYPE_SIZE (gnu_field_type));
|
||||||
|
|
||||||
|
else if (is_volatile)
|
||||||
|
post_error_ne_tree
|
||||||
|
("volatile field& must be natural size of type{ (^)}",
|
||||||
|
Last_Bit (Component_Clause (gnat_field)), gnat_field,
|
||||||
|
TYPE_SIZE (gnu_field_type));
|
||||||
|
|
||||||
else if (Is_Aliased (gnat_field))
|
else if (Is_Aliased (gnat_field))
|
||||||
post_error_ne_tree
|
post_error_ne_tree
|
||||||
("size of aliased field& must be ^ bits",
|
("size of aliased field& must be ^ bits",
|
||||||
|
|
@ -6520,6 +6527,9 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed,
|
||||||
Last_Bit (Component_Clause (gnat_field)), gnat_field,
|
Last_Bit (Component_Clause (gnat_field)), gnat_field,
|
||||||
TYPE_SIZE (gnu_field_type));
|
TYPE_SIZE (gnu_field_type));
|
||||||
|
|
||||||
|
else
|
||||||
|
gcc_unreachable ();
|
||||||
|
|
||||||
gnu_size = NULL_TREE;
|
gnu_size = NULL_TREE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -6527,7 +6537,13 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed,
|
||||||
(TRUNC_MOD_EXPR, gnu_pos,
|
(TRUNC_MOD_EXPR, gnu_pos,
|
||||||
bitsize_int (TYPE_ALIGN (gnu_field_type)))))
|
bitsize_int (TYPE_ALIGN (gnu_field_type)))))
|
||||||
{
|
{
|
||||||
if (is_volatile)
|
if (Is_Atomic (gnat_field) || Is_Atomic (gnat_field_type))
|
||||||
|
post_error_ne_num
|
||||||
|
("position of atomic field& must be multiple of ^ bits",
|
||||||
|
First_Bit (Component_Clause (gnat_field)), gnat_field,
|
||||||
|
TYPE_ALIGN (gnu_field_type));
|
||||||
|
|
||||||
|
else if (is_volatile)
|
||||||
post_error_ne_num
|
post_error_ne_num
|
||||||
("position of volatile field& must be multiple of ^ bits",
|
("position of volatile field& must be multiple of ^ bits",
|
||||||
First_Bit (Component_Clause (gnat_field)), gnat_field,
|
First_Bit (Component_Clause (gnat_field)), gnat_field,
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
2013-01-06 Olivier Hainque <hainque@adacore.com>
|
||||||
|
|
||||||
|
* gnat.dg/specs/clause_on_volatile.ads: New test.
|
||||||
|
|
||||||
2013-01-06 Eric Botcazou <ebotcazou@adacore.com>
|
2013-01-06 Eric Botcazou <ebotcazou@adacore.com>
|
||||||
|
|
||||||
* gnat.dg/alignment10.adb: New test.
|
* gnat.dg/alignment10.adb: New test.
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,85 @@
|
||||||
|
-- { dg-do compile }
|
||||||
|
|
||||||
|
package Clause_On_Volatile is
|
||||||
|
|
||||||
|
type U8 is mod 2 ** 8;
|
||||||
|
|
||||||
|
type Word is record
|
||||||
|
A, B : U8;
|
||||||
|
end record;
|
||||||
|
For Word'Alignment use 4;
|
||||||
|
|
||||||
|
type Vword is new Word;
|
||||||
|
For Vword'Alignment use 4;
|
||||||
|
pragma Volatile (Vword);
|
||||||
|
|
||||||
|
type Aword is new Word;
|
||||||
|
For Aword'Alignment use 4;
|
||||||
|
pragma Atomic (Aword);
|
||||||
|
|
||||||
|
type R1 is record
|
||||||
|
W : Word;
|
||||||
|
end record;
|
||||||
|
for R1 use record
|
||||||
|
W at 0 range 0 .. 15; -- OK, packing regular
|
||||||
|
end record;
|
||||||
|
|
||||||
|
type A1 is record
|
||||||
|
AW : Aword;
|
||||||
|
end record;
|
||||||
|
For A1'Alignment use 4;
|
||||||
|
for A1 use record
|
||||||
|
AW at 0 range 0 .. 15; -- { dg-error "must be natural size" }
|
||||||
|
end record;
|
||||||
|
|
||||||
|
type A2 is record
|
||||||
|
B : U8;
|
||||||
|
AW : Aword;
|
||||||
|
end record;
|
||||||
|
For A2'Alignment use 4;
|
||||||
|
for A2 use record
|
||||||
|
B at 0 range 0 .. 7;
|
||||||
|
AW at 1 range 0 .. 31; -- { dg-error "must be multiple" }
|
||||||
|
end record;
|
||||||
|
|
||||||
|
type A3 is record
|
||||||
|
B : U8;
|
||||||
|
AW : Aword;
|
||||||
|
end record;
|
||||||
|
For A3'Alignment use 4;
|
||||||
|
for A3 use record
|
||||||
|
B at 0 range 0 .. 7;
|
||||||
|
AW at 1 range 0 .. 15; -- { dg-error "must be (multiple|natural size)" }
|
||||||
|
end record;
|
||||||
|
|
||||||
|
--
|
||||||
|
|
||||||
|
type V1 is record
|
||||||
|
VW : Vword;
|
||||||
|
end record;
|
||||||
|
For V1'Alignment use 4;
|
||||||
|
for V1 use record
|
||||||
|
VW at 0 range 0 .. 15; -- { dg-error "must be natural size" }
|
||||||
|
end record;
|
||||||
|
|
||||||
|
type V2 is record
|
||||||
|
B : U8;
|
||||||
|
VW : Vword;
|
||||||
|
end record;
|
||||||
|
For V2'Alignment use 4;
|
||||||
|
for V2 use record
|
||||||
|
B at 0 range 0 .. 7;
|
||||||
|
VW at 1 range 0 .. 31; -- { dg-error "must be multiple" }
|
||||||
|
end record;
|
||||||
|
|
||||||
|
type V3 is record
|
||||||
|
B : U8;
|
||||||
|
VW : Vword;
|
||||||
|
end record;
|
||||||
|
For V3'Alignment use 4;
|
||||||
|
for V3 use record
|
||||||
|
B at 0 range 0 .. 7;
|
||||||
|
VW at 1 range 0 .. 15; -- { dg-error "must be (multiple|natural size)" }
|
||||||
|
end record;
|
||||||
|
|
||||||
|
end Clause_On_Volatile;
|
||||||
Loading…
Reference in New Issue