diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2017-05-22 08:17:40 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2017-05-22 08:17:40 +0000 |
commit | 4c24ec6d58db238f64bda456ebdb0b5c82347d78 (patch) | |
tree | 8656c279a45119f7d0d0882057fc590a6e2d760c /gcc | |
parent | 772cd69487596ab91845ef4a0e4ace6c8433892a (diff) | |
download | gcc-4c24ec6d58db238f64bda456ebdb0b5c82347d78.zip gcc-4c24ec6d58db238f64bda456ebdb0b5c82347d78.tar.gz gcc-4c24ec6d58db238f64bda456ebdb0b5c82347d78.tar.bz2 |
decl.c (gnat_to_gnu_field): Do not enforce strict alignment for simple volatile fields and remove...
* gcc-interface/decl.c (gnat_to_gnu_field): Do not enforce strict
alignment for simple volatile fields and remove associated errors.
testsuite/
* gnat.dg/specs/volatile1.ads: Remove obsolete errors.
* gnat.dg/specs/clause_on_volatile.ads: Likewise.
From-SVN: r248320
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/decl.c | 34 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/specs/clause_on_volatile.ads | 6 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/specs/volatile1.ads | 2 |
5 files changed, 30 insertions, 22 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 1c12460..e7d5692 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2017-05-22 Eric Botcazou <ebotcazou@adacore.com> + + * gcc-interface/decl.c (gnat_to_gnu_field): Do not enforce strict + alignment for simple volatile fields and remove associated errors. + 2017-05-15 Eric Botcazou <ebotcazou@adacore.com> * gcc-interface/gigi.h (get_elaboration_procedure): Delete. diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index dee59c0..4bf1464 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -6783,19 +6783,24 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed, { const Entity_Id gnat_record_type = Underlying_Type (Scope (gnat_field)); const Entity_Id gnat_field_type = Etype (gnat_field); - const bool is_aliased - = Is_Aliased (gnat_field); const bool is_atomic = (Is_Atomic_Or_VFA (gnat_field) || Is_Atomic_Or_VFA (gnat_field_type)); + const bool is_aliased = Is_Aliased (gnat_field); const bool is_independent = (Is_Independent (gnat_field) || Is_Independent (gnat_field_type)); const bool is_volatile = (Treat_As_Volatile (gnat_field) || Treat_As_Volatile (gnat_field_type)); + const bool is_strict_alignment = Strict_Alignment (gnat_field_type); + /* We used to consider that volatile fields also require strict alignment, + but that was an interpolation and would cause us to reject a pragma + volatile on a packed record type containing boolean components, while + there is no basis to do so in the RM. In such cases, the writes will + involve load-modify-store sequences, but that's OK for volatile. The + only constraint is the implementation advice whereby only the bits of + the components should be accessed if they both start and end on byte + boundaries, but that should be guaranteed by the GCC memory model. */ const bool needs_strict_alignment - = (is_aliased - || is_independent - || is_volatile - || Strict_Alignment (gnat_field_type)); + = (is_atomic || is_aliased || is_independent || is_strict_alignment); tree gnu_field_type = gnat_to_gnu_type (gnat_field_type); tree gnu_field_id = get_entity_name (gnat_field); tree gnu_field, gnu_size, gnu_pos; @@ -6917,9 +6922,7 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed, s = "position of aliased field& must be multiple of ^ bits"; else if (is_independent) s = "position of independent field& must be multiple of ^ bits"; - else if (is_volatile) - s = "position of volatile field& must be multiple of ^ bits"; - else if (Strict_Alignment (gnat_field_type)) + else if (is_strict_alignment) s = "position of & with aliased or tagged part must be" " multiple of ^ bits"; else @@ -6947,9 +6950,7 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed, s = "size of aliased field& must be ^ bits"; else if (is_independent) s = "size of independent field& must be at least ^ bits"; - else if (is_volatile) - s = "size of volatile field& must be at least ^ bits"; - else if (Strict_Alignment (gnat_field_type)) + else if (is_strict_alignment) s = "size of & with aliased or tagged part must be" " at least ^ bits"; else @@ -6969,10 +6970,7 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed, if (is_independent) s = "size of independent field& must be multiple of" " Storage_Unit"; - else if (is_volatile) - s = "size of volatile field& must be multiple of" - " Storage_Unit"; - else if (Strict_Alignment (gnat_field_type)) + else if (is_strict_alignment) s = "size of & with aliased or tagged part must be" " multiple of Storage_Unit"; else @@ -7079,9 +7077,9 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed, /* Now create the decl for the field. */ gnu_field = create_field_decl (gnu_field_id, gnu_field_type, gnu_record_type, - gnu_size, gnu_pos, packed, Is_Aliased (gnat_field)); + gnu_size, gnu_pos, packed, is_aliased); Sloc_to_locus (Sloc (gnat_field), &DECL_SOURCE_LOCATION (gnu_field)); - DECL_ALIASED_P (gnu_field) = Is_Aliased (gnat_field); + DECL_ALIASED_P (gnu_field) = is_aliased; TREE_SIDE_EFFECTS (gnu_field) = TREE_THIS_VOLATILE (gnu_field) = is_volatile; if (Ekind (gnat_field) == E_Discriminant) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0ae3270..575ed96 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-05-22 Eric Botcazou <ebotcazou@adacore.com> + + * gnat.dg/specs/volatile1.ads: Remove obsolete errors. + * gnat.dg/specs/clause_on_volatile.ads: Likewise. + 2017-05-21 Paolo Carlini <paolo.carlini@oracle.com> PR c++/70265 diff --git a/gcc/testsuite/gnat.dg/specs/clause_on_volatile.ads b/gcc/testsuite/gnat.dg/specs/clause_on_volatile.ads index 68799a7..f4c0b98 100644 --- a/gcc/testsuite/gnat.dg/specs/clause_on_volatile.ads +++ b/gcc/testsuite/gnat.dg/specs/clause_on_volatile.ads @@ -57,7 +57,7 @@ package Clause_On_Volatile is end record; For V1'Alignment use 4; for V1 use record - VW at 0 range 0 .. 15; -- { dg-error "must be at least" } + VW at 0 range 0 .. 15; end record; type V2 is record @@ -67,7 +67,7 @@ package Clause_On_Volatile is 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" } + VW at 1 range 0 .. 31; end record; type V3 is record @@ -77,7 +77,7 @@ package Clause_On_Volatile is 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|at least)" } + VW at 1 range 0 .. 15; end record; end Clause_On_Volatile; diff --git a/gcc/testsuite/gnat.dg/specs/volatile1.ads b/gcc/testsuite/gnat.dg/specs/volatile1.ads index 40ad480..6f9421a 100644 --- a/gcc/testsuite/gnat.dg/specs/volatile1.ads +++ b/gcc/testsuite/gnat.dg/specs/volatile1.ads @@ -19,7 +19,7 @@ package Volatile1 is pragma Volatile (C); end record; for R2 use record - C at 0 range 0 .. 10; -- { dg-error "size of volatile field" } + C at 0 range 0 .. 10; end record; end Volatile1; |