From patchwork Wed Dec 5 10:30:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 203822 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 87FB92C0092 for ; Wed, 5 Dec 2012 21:30:46 +1100 (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=1355308246; 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=sTI4MaEgADtl4rM/1xcb QnPkCK0=; b=mzizmrw9vTQXeBgnEHxG64ar2uZirFaguW2mM+knzAFqGYrH7B9n DwNWd7p1EkQaEmTLB2u67KPoF3/x9A3xk0WDDSOJftm92lA1TwHn29cqcHH+w3Dv xkC4MMy1IEOmlLgmJbTwpvx5SGd38ZqJFaaA6zqBJGo3R0w3Ob7P48I= 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=D3jRhHf9OS5N9xOGeTVCRxhjXx/HC/RN+xEn55rTuQp/BSm7D7NqmDfbhcuAz+ YlzTTKSd+l4NLNkiT94BLrWkFGeb9hWdkzpBBjEjzbcUFQJlI0PIbzA0jye3piHa k9EmIp7uC3zRSkum4/VHsvIyoByAFqpWbGiCWeIuNzg+w=; Received: (qmail 15299 invoked by alias); 5 Dec 2012 10:30:31 -0000 Received: (qmail 15242 invoked by uid 22791); 5 Dec 2012 10:30:29 -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; Wed, 05 Dec 2012 10:30:21 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id CD5752E374; Wed, 5 Dec 2012 05:30:20 -0500 (EST) 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 MY6FtrRPb9hC; Wed, 5 Dec 2012 05:30:20 -0500 (EST) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id BDFCE2E0E6; Wed, 5 Dec 2012 05:30:19 -0500 (EST) Received: by kwai.gnat.com (Postfix, from userid 4192) id BCE20919E3; Wed, 5 Dec 2012 05:30:19 -0500 (EST) Date: Wed, 5 Dec 2012 05:30:19 -0500 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Visibility of equality operator when left operand is null. Message-ID: <20121205103019.GA4582@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 If the left operand of an equality operator is null, the visibility of the operator must be determined from the interpretation of the right operand. This processing was done for universal numeric types but not for Any_Access, the internal representation of the type of the literal null. Compiling my_procedure.adb must yield the error message: my_procedure.adb:7:12: operator for type "My_Access" defined at myproc_types.ads:3 is not directly visible my_procedure.adb:7:12: use clause would make operation legal --- with Ada.Text_IO; with MyProc_Types; procedure My_Procedure is Local : MyProc_Types.My_Access; begin if null /= Local then -- ERROR: use clause needed Ada.Text_IO.Put_Line ("Branch A"); else Ada.Text_IO.Put_Line ("Branch B"); end if; end My_Procedure; --- package MyProc_Types is type My_Record is limited private; type My_Access is access all My_Record; private type My_Record is null record; end MyProc_Types; Tested on x86_64-pc-linux-gnu, committed on trunk 2012-12-05 Ed Schonberg * sem_ch4.adb (Find_Non_Universal_Interpretation): Use the types of the right operand if the left operand is null. Index: sem_ch4.adb =================================================================== --- sem_ch4.adb (revision 194188) +++ sem_ch4.adb (working copy) @@ -192,7 +192,9 @@ -- of the operand types. If one of the operands has a universal interpre- -- tation, the legality check uses some compatible non-universal -- interpretation of the other operand. N can be an operator node, or - -- a function call whose name is an operator designator. + -- a function call whose name is an operator designator. Any_Access, which + -- is the initial type of the literal NULL, is a universal type for the + -- purpose of this routine. function Find_Primitive_Operation (N : Node_Id) return Boolean; -- Find candidate interpretations for the name Obj.Proc when it appears @@ -5504,6 +5506,7 @@ begin if T1 = Universal_Integer or else T1 = Universal_Real + or else T1 = Any_Access then if not Is_Overloaded (R) then Add_One_Interp