From patchwork Fri Oct 8 10:17:23 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 67159 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 6C074B70AF for ; Fri, 8 Oct 2010 21:17:33 +1100 (EST) Received: (qmail 19290 invoked by alias); 8 Oct 2010 10:17:31 -0000 Received: (qmail 19277 invoked by uid 22791); 8 Oct 2010 10:17:30 -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; Fri, 08 Oct 2010 10:17:26 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id E38ABCB0278; Fri, 8 Oct 2010 12:17: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 G1Xv9u6swaoO; Fri, 8 Oct 2010 12:17: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 D15DFCB01F0; Fri, 8 Oct 2010 12:17:23 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id B28B7D9BB4; Fri, 8 Oct 2010 12:17:23 +0200 (CEST) Date: Fri, 8 Oct 2010 12:17:23 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Defaults that raise constraint_error Message-ID: <20101008101723.GA10314@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 When a default value is inserted in a list of actuals, if the default is known to raise constraint error it is replaced with an explicit raise node and a warning is emitted. The default value may already be a Raise_Constraint_Error node for example if it appears in a nested instantiation. In such a case the node should not be rewritten, to prevent loops in the machinery that removes warnings from code that is not in the main unit. No simple example available. Tested on x86_64-pc-linux-gnu, committed on trunk 2010-10-08 Ed Schonberg * sem_res.adb (Insert_Default): If default value is already a raise_constraint_error do not rewrite it as new raise node, to prevent infinite loops in the warning removal machinery. Index: sem_res.adb =================================================================== --- sem_res.adb (revision 165104) +++ sem_res.adb (working copy) @@ -3120,8 +3120,12 @@ package body Sem_Res is -- If the default expression raises constraint error, then just -- silently replace it with an N_Raise_Constraint_Error node, -- since we already gave the warning on the subprogram spec. + -- If node is already a Raise_Constraint_Error leave as is, to + -- prevent loops in the warnings removal machinery. - if Raises_Constraint_Error (Actval) then + if Raises_Constraint_Error (Actval) + and then Nkind (Actval) /= N_Raise_Constraint_Error + then Rewrite (Actval, Make_Raise_Constraint_Error (Loc, Reason => CE_Range_Check_Failed));