From patchwork Mon Aug 6 07:59:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 175289 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 DCFD32C00A0 for ; Mon, 6 Aug 2012 17:59:34 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1344844775; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=E0tx/Gfdow/czyeboWWo KArjmyU=; b=KaSzzm9TePKMvxveMDWvdRpEegKEtSHj6wSRt1dTNiCG4J/NwR+s t5ZFHVxU6A5eaceB6ViBenbRm6ZtNWzaTbzC3i4ivhl6Y3tFnhhUvOlpH0ZOz5Kj 2/ba7iKHEbasgNgDoPfKh7LCH6XFxPlHkgW+WQ+B6r02X7spawkPgiE= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=gCJLLRDZ2acpokhe0kAPDdmhKB7ATyo/o/4GJjZANba4ZH+x5pjodK8DxOUu7M +JFwX149JU7MUGjLW4LC40ohf+rRByoDghA5yEUJSIJnEcPlWjWS1L7zrtUBWWgD //WPApPnyTEShcAe255FltAUGLHMJCgn/CFBsDllZbXog=; Received: (qmail 14277 invoked by alias); 6 Aug 2012 07:59:31 -0000 Received: (qmail 14267 invoked by uid 22791); 6 Aug 2012 07:59:30 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_NO X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 06 Aug 2012 07:59:17 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 39C061C750B; Mon, 6 Aug 2012 03:59:17 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id BhPNcb05aBEH; Mon, 6 Aug 2012 03:59:17 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 19B1F1C7508; Mon, 6 Aug 2012 03:59:17 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 1B0B592BF6; Mon, 6 Aug 2012 03:59:17 -0400 (EDT) Date: Mon, 6 Aug 2012 03:59:17 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Vincent Pucci Subject: [Ada] Fix delayed analysis of aspect specification when scopes differ Message-ID: <20120806075917.GA5588@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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 This patch properly analyses aspects in cases when scopes differ such as protected types, tasks, etc. The test illustrates the analysis of aspects at freeze point specified for a protected object. ------------ -- Source -- ------------ package T is type Typ is new Integer with Size => 128; protected type Prot with Lock_Free => True is procedure Reset; private Counter : Typ := 0; end Prot; end T; package body T is protected body Prot is procedure Reset is begin Counter := 0; end Reset; end Prot; end T; ----------------- -- Compilation -- ----------------- $ gnatmake -q -gnat12 t.adb t.adb:3:07: illegal body when Lock_Free given t.adb:5:10: type of "Counter" must support atomic operations gnatmake: "t.adb" compilation error Tested on x86_64-pc-linux-gnu, committed on trunk 2012-08-06 Vincent Pucci * sem_ch13.adb: Current scope must be within or same as the scope of the entity while analysing aspect specifications at freeze point. Index: sem_ch13.adb =================================================================== --- sem_ch13.adb (revision 190155) +++ sem_ch13.adb (working copy) @@ -856,10 +856,11 @@ -- Start of processing for Analyze_Aspects_At_Freeze_Point begin - -- Must be declared in current scope. This is need for a generic - -- context. + -- Must be visible in current scope. Note that this is needed for + -- entities that creates their own scope such as protected objects, + -- tasks, etc. - if Scope (E) /= Current_Scope then + if not Scope_Within_Or_Same (Current_Scope, Scope (E)) then return; end if; @@ -2434,11 +2435,12 @@ return; -- Must be declared in current scope or in case of an aspect - -- specification, must be the current scope. + -- specification, must be visible in current scope. elsif Scope (Ent) /= Current_Scope - and then (not From_Aspect_Specification (N) - or else Ent /= Current_Scope) + and then + not (From_Aspect_Specification (N) + and then Scope_Within_Or_Same (Current_Scope, Scope (Ent))) then Error_Msg_N ("entity must be declared in this scope", Nam); return;