From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26760 invoked by alias); 27 Jun 2005 20:48:02 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 26716 invoked by uid 22791); 27 Jun 2005 20:47:58 -0000 Received: from vlsi1.ultra.nyu.edu (HELO vlsi1.ultra.nyu.edu) (128.122.140.213) by sourceware.org (qpsmtpd/0.30-dev) with SMTP; Mon, 27 Jun 2005 20:47:58 +0000 Received: by vlsi1.ultra.nyu.edu (4.1/1.34) id AA09083; Mon, 27 Jun 05 16:49:55 EDT Date: Mon, 27 Jun 2005 20:48:00 -0000 From: kenner@vlsi1.ultra.nyu.edu (Richard Kenner) Message-Id: <10506272049.AA09083@vlsi1.ultra.nyu.edu> To: dnovillo@redhat.com Subject: Re: Q about Ada and value ranges in types Cc: gcc@gcc.gnu.org X-SW-Source: 2005-06/txt/msg01065.txt.bz2 Sorry it took me so long to get to this. > You're not showing where this comes from, so it's hard to say. However > D.1480 is created by the gimplifier, not the Ada front end. There could > easily be a typing problem in the tree there (e.g., that of the > subtraction) but I can't tell for sure. As it turned out, there was. So, after calling sinfo__chars() and subtracting 300000361, the FE is emitting that range check. AFAICT, the call to sinfo__chars(e_5) comes from ada/sem_intr.adb:148 Nam : constant Name_Id := Chars (E); and 'if (D.1480_32 <= 1)' is at line 155: I'd also assumed this was where the bogus tree came from, but I was wrong. The node in question was not made by the Ada front end but by build_range_check in clearly incorrect code that does the subtraction in the wrong type. This fixes that problem. Are you in a position to check if it fixes the original issue? *** fold-const.c 25 Jun 2005 01:59:57 -0000 1.599 --- fold-const.c 27 Jun 2005 20:44:56 -0000 *************** build_range_check (tree type, tree exp, *** 4027,4034 **** if (value != 0 && ! TREE_OVERFLOW (value)) ! return build_range_check (type, ! fold_build2 (MINUS_EXPR, etype, exp, low), ! 1, fold_convert (etype, integer_zero_node), ! value); return 0; --- 4027,4045 ---- if (value != 0 && ! TREE_OVERFLOW (value)) ! { ! /* There is no requirement that LOW be within the range of ETYPE ! if the latter is a subtype. It must, however, be within the base ! type of ETYPE. So be sure we do the subtraction in that type. */ ! if (TREE_TYPE (etype)) ! { ! etype = TREE_TYPE (etype); ! value = fold_convert (etype, value); ! } ! ! return build_range_check (type, ! fold_build2 (MINUS_EXPR, etype, exp, low), ! 1, fold_convert (etype, integer_zero_node), ! value); ! } return 0;