From patchwork Wed Jun 23 09:15:22 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 56619 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 C0A45B6F0E for ; Wed, 23 Jun 2010 19:15:31 +1000 (EST) Received: (qmail 19820 invoked by alias); 23 Jun 2010 09:15:28 -0000 Received: (qmail 19794 invoked by uid 22791); 23 Jun 2010 09:15:26 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 23 Jun 2010 09:15:20 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id D3E6ECB025B; Wed, 23 Jun 2010 11:15:23 +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 FUgpn3DwDmsl; Wed, 23 Jun 2010 11:15:23 +0200 (CEST) Received: from saumur.act-europe.fr (saumur.act-europe.fr [10.10.0.183]) by mel.act-europe.fr (Postfix) with ESMTP id C02BCCB024B; Wed, 23 Jun 2010 11:15:23 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id 11AA2D9BA8; Wed, 23 Jun 2010 11:15:22 +0200 (CEST) Date: Wed, 23 Jun 2010 11:15:22 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Membership operations on fixed point universal arguments Message-ID: <20100623091522.GA18716@adacore.com> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.9i X-IsSubscribed: yes 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 With this patch the compiler handles properly the case of a membership op. where the left operand is of any fixed point type because it is a mixed-mode operation with universal operands, and the right operand is a range with universal bounds. The following must compile and produce the warning: bug.adb:4:26: warning: universal_fixed expression interpreted as type "Standard.Duration" procedure Bug is Nr1: Integer := 15; -- Works when variables are float begin if (Nr1 - 1) * 20.0E-6 in 0.75E-3 .. 1.15E-3 then null; else null; end if; end Bug; Tested on x86_64-pc-linux-gnu, committed on trunk 2010-06-23 Ed Schonberg * sem_res.adb (Resolve_Membership_Op): If left operand is a mixed mode operation with a universal real operand, and the right operand is a range with universal bounds, find unique fixed point that may be candidate, and warn appropriately. Index: sem_res.adb =================================================================== --- sem_res.adb (revision 161263) +++ sem_res.adb (working copy) @@ -7036,6 +7036,18 @@ package body Sem_Res is T := Intersect_Types (L, R); end if; + -- If mixed-mode operations are present and operands are all literal, + -- the only interpretation involves Duration, which is probably not + -- the intention of the programmer. + + if T = Any_Fixed then + T := Unique_Fixed_Point_Type (N); + + if T = Any_Type then + return; + end if; + end if; + Resolve (L, T); Check_Unset_Reference (L);