From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 77637 invoked by alias); 22 May 2017 08:17:55 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 77551 invoked by uid 89); 22 May 2017 08:17:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=boundaries, enforce, whereby X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 22 May 2017 08:17:50 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id B80F78133F for ; Mon, 22 May 2017 10:17:51 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lWrdgd2_udHT for ; Mon, 22 May 2017 10:17:51 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 8C6308133D for ; Mon, 22 May 2017 10:17:51 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Relax restrictions on volatile components Date: Mon, 22 May 2017 08:46:00 -0000 Message-ID: <115036059.M0ml5omx4d@polaris> User-Agent: KMail/4.14.10 (Linux/3.16.7-53-desktop; KDE/4.14.9; x86_64; ; ) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart1759406.8S3ELoBrXT" Content-Transfer-Encoding: 7Bit X-SW-Source: 2017-05/txt/msg01656.txt.bz2 This is a multi-part message in MIME format. --nextPart1759406.8S3ELoBrXT Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Content-length: 540 GNAT has historically enforced strong restrictions on volatile components, but this is no basis for that in the RM. Tested on x86_64-suse-linux, applied on the mainline. 2017-05-22 Eric Botcazou * gcc-interface/decl.c (gnat_to_gnu_field): Do not enforce strict alignment for simple volatile fields and remove associated errors. 2017-05-22 Eric Botcazou * gnat.dg/specs/volatile1.ads: Remove obsolete errors. * gnat.dg/specs/clause_on_volatile.ads: Likewise. -- Eric Botcazou --nextPart1759406.8S3ELoBrXT Content-Disposition: attachment; filename="p.diff" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="p.diff" Content-length: 5407 Index: ada/gcc-interface/decl.c =================================================================== --- ada/gcc-interface/decl.c (revision 248140) +++ ada/gcc-interface/decl.c (working copy) @@ -6783,19 +6783,24 @@ gnat_to_gnu_field (Entity_Id gnat_field, { 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, 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, 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, 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, /* 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) Index: testsuite/gnat.dg/specs/clause_on_volatile.ads =================================================================== --- testsuite/gnat.dg/specs/clause_on_volatile.ads (revision 248140) +++ testsuite/gnat.dg/specs/clause_on_volatile.ads (working copy) @@ -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; Index: testsuite/gnat.dg/specs/volatile1.ads =================================================================== --- testsuite/gnat.dg/specs/volatile1.ads (revision 248140) +++ testsuite/gnat.dg/specs/volatile1.ads (working copy) @@ -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; --nextPart1759406.8S3ELoBrXT--