From patchwork Wed Apr 20 09:05:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 612582 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qqbZD2bD2z9sBm for ; Wed, 20 Apr 2016 19:05:24 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=o/cab9tv; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=Ujx651oDHH1SJ0Hr6EkRu3ms2zmCLKFUxhOKlScACGwTI9nm32 jNPKouuUDTniIM3PbV7Li+yt2th65VQGhh8h9j7DQAXYVwcPhckeC01QIThCJ6tX e/j6p8U8UUHGLCkAcK7Z/aUXt2K+VE8g4soXLpnC1GIUNkjphrG2UDEEA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=dTIdjZ2DxsXoVYD/ywmwVQKym9A=; b=o/cab9tvlV4RmzpQ83jK fuHD/ufYOQ0bYkbR19hHFO9lnRJMvQVoAjzK5srnlwz7LK/QtSuA7J/FV5+ix9Vn CkK0SMBI+bCEeYRrSXL3+P6T8zveaTPhyyuL3R3jxdg5b4y4cHx+6kU26M57J5IZ UWcHmN7bdGP98OYKeRrHu/k= Received: (qmail 14229 invoked by alias); 20 Apr 2016 09:05:16 -0000 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 Received: (qmail 14213 invoked by uid 89); 20 Apr 2016 09:05:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.8 required=5.0 tests=BAYES_50, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.2 spammy=elsif, Etype, schonbergadacorecom, schonberg@adacore.com X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 20 Apr 2016 09:05:14 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id B6C74116BD1; Wed, 20 Apr 2016 05:05:12 -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 5WHyOvPyBVYl; Wed, 20 Apr 2016 05:05:12 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) by rock.gnat.com (Postfix) with ESMTP id A712F116BC2; Wed, 20 Apr 2016 05:05:12 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4192) id A63293ED; Wed, 20 Apr 2016 05:05:12 -0400 (EDT) Date: Wed, 20 Apr 2016 05:05:12 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Spurious error in if_expression with universal then_expression Message-ID: <20160420090512.GA123172@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) If the first branch of an if-expression is a literal, remaining expressions can resolve to any integer type (or any real type depending on the literal). Tested in ACATS 4.0J test B457007 Tested on x86_64-pc-linux-gnu, committed on trunk 2016-04-20 Ed Schonberg * sem_res.adb (Resolve_If_Expression): If first expression is universal, resolve subsequent ones with the corresponding class type (Any_Integer or Any_Real). Index: sem_res.adb =================================================================== --- sem_res.adb (revision 235200) +++ sem_res.adb (working copy) @@ -8048,9 +8048,19 @@ end if; -- If ELSE expression present, just resolve using the determined type + -- If type is universal, resolve to any member of the class. if Present (Else_Expr) then - Resolve (Else_Expr, Typ); + if Typ = Universal_Integer then + Resolve (Else_Expr, Any_Integer); + + elsif Typ = Universal_Real then + Resolve (Else_Expr, Any_Real); + + else + Resolve (Else_Expr, Typ); + end if; + Else_Typ := Etype (Else_Expr); if Is_Scalar_Type (Else_Typ) and then Else_Typ /= Typ then