From patchwork Wed Oct 26 20:28:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 121996 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 038F21007D2 for ; Thu, 27 Oct 2011 07:33:09 +1100 (EST) Received: (qmail 14007 invoked by alias); 26 Oct 2011 20:33:02 -0000 Received: (qmail 13962 invoked by uid 22791); 26 Oct 2011 20:32:59 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 26 Oct 2011 20:32:42 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 021FCCB02C6 for ; Wed, 26 Oct 2011 22:32:43 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id o188Qg36758G for ; Wed, 26 Oct 2011 22:32:33 +0200 (CEST) Received: from [192.168.1.2] (bon31-9-83-155-120-49.fbx.proxad.net [83.155.120.49]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 31B12CB0257 for ; Wed, 26 Oct 2011 22:32:33 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Missing error for invalid atomic component Date: Wed, 26 Oct 2011 22:28:19 +0200 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Message-Id: <201110262228.19746.ebotcazou@adacore.com> Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org The compiler should issue the "atomic access cannot be guaranteed" error twice on the attached testcase, but it only issues it for the stand-alone variable. Fixed thusly, tested on i586-suse-linux, applied on the mainline. 2011-10-26 Eric Botcazou * gcc-interface/decl.c (gnat_to_gnu_field): Always check components declared as atomic. Move around conditionally executed code. 2011-10-26 Eric Botcazou * gnat.dg/specs/atomic1.ads: New test. Index: gcc-interface/decl.c =================================================================== --- gcc-interface/decl.c (revision 180423) +++ gcc-interface/decl.c (working copy) @@ -6853,10 +6853,8 @@ gnat_to_gnu_field (Entity_Id gnat_field, } } - /* If we are packing the record and the field is BLKmode, round the - size up to a byte boundary. */ - if (packed && TYPE_MODE (gnu_field_type) == BLKmode && gnu_size) - gnu_size = round_up (gnu_size, BITS_PER_UNIT); + if (Is_Atomic (gnat_field)) + check_ok_for_atomic (gnu_field_type, gnat_field, false); if (Present (Component_Clause (gnat_field))) { @@ -6946,9 +6944,6 @@ gnat_to_gnu_field (Entity_Id gnat_field, gnu_pos = NULL_TREE; } } - - if (Is_Atomic (gnat_field)) - check_ok_for_atomic (gnu_field_type, gnat_field, false); } /* If the record has rep clauses and this is the tag field, make a rep @@ -6961,7 +6956,14 @@ gnat_to_gnu_field (Entity_Id gnat_field, } else - gnu_pos = NULL_TREE; + { + gnu_pos = NULL_TREE; + + /* If we are packing the record and the field is BLKmode, round the + size up to a byte boundary. */ + if (packed && TYPE_MODE (gnu_field_type) == BLKmode && gnu_size) + gnu_size = round_up (gnu_size, BITS_PER_UNIT); + } /* We need to make the size the maximum for the type if it is self-referential and an unconstrained type. In that case, we can't