From patchwork Wed Jul 18 12:21:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 171660 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 525E92C0358 for ; Wed, 18 Jul 2012 22:22:02 +1000 (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=1343218923; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Subject:Date:User-Agent:MIME-Version:Message-Id: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=hIxxLXu 8spJ4Z125tcrolzOxATc=; b=LFeZjZoqdGxsbrH0QGUrs1qkXKiA4SSZMGpHhgd FimU0BK7THet2b2SC2mGXsPOR5/XWjPJ5Fz7nfhuklzaiAb4RH80gZmnCDzsPHfj aqhaFqKb3X46jP0Qa6vHDt8MjK9dCa27y4Xx+rS7vxxHiTwegHJxuu31/XsZK5Ll O/2c= 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:From:To:Subject:Date:User-Agent:MIME-Version:Message-Id:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=ts0z4tmlk9MoaTwIHFvzkmufKF7FUDf0O5PPZB5T9jCN2IhVQ6J0YL5SSXlmBj 33CEZzCIUxI/suim1xRb6W5+2sBVgScLJOo2OLH4UKewt333sdM/nDRK3VH1iMrW 4h/G4/zK1UVdBklCjg2/apaW5g2aAdBcN6LA4ll/esyso=; Received: (qmail 10708 invoked by alias); 18 Jul 2012 12:21:51 -0000 Received: (qmail 10692 invoked by uid 22791); 18 Jul 2012 12:21:45 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,TW_TM X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 18 Jul 2012 12:21:31 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id BFF6A290053 for ; Wed, 18 Jul 2012 14:21:34 +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 4YWkuIH4eSQu for ; Wed, 18 Jul 2012 14:21:34 +0200 (CEST) Received: from hermes.site (ADijon-552-1-101-157.w90-33.abo.wanadoo.fr [90.33.60.157]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 794ED29000B for ; Wed, 18 Jul 2012 14:21:34 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix spurious 'noreturn' function does return warning at -O0 (1) Date: Wed, 18 Jul 2012 14:21:27 +0200 User-Agent: KMail/1.13.5 (Linux/2.6.34.10-0.6-desktop; KDE/4.4.4; x86_64; ; ) MIME-Version: 1.0 Message-Id: <201207181421.27464.ebotcazou@adacore.com> 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 This fixes a spurious 'noreturn' function does return warning at -O0 on code involving controlled types. Tested on x86_64-suse-linux, applied on the mainline. 2012-07-18 Eric Botcazou * gcc-interface/trans.c (stmt_group_may_fallthru): New function. (gnat_to_gnu) : Use it to find out whether the block needs to be translated. 2012-07-18 Eric Botcazou * gnat.dg/noreturn4.ad[sb]: New test. * gnat.dg/noreturn4_pkg.ads: New helper. Index: gcc-interface/trans.c =================================================================== --- gcc-interface/trans.c (revision 189607) +++ gcc-interface/trans.c (working copy) @@ -244,6 +244,7 @@ static void add_cleanup (tree, Node_Id); static void add_stmt_list (List_Id); static void push_exception_label_stack (VEC(tree,gc) **, Entity_Id); static tree build_stmt_group (List_Id, bool); +static inline bool stmt_group_may_fallthru (void); static enum gimplify_status gnat_gimplify_stmt (tree *); static void elaborate_all_entities (Node_Id); static void process_freeze_entity (Node_Id); @@ -6197,12 +6198,18 @@ gnat_to_gnu (Node_Id gnat_node) break; case N_Block_Statement: - start_stmt_group (); - gnat_pushlevel (); - process_decls (Declarations (gnat_node), Empty, Empty, true, true); - add_stmt (gnat_to_gnu (Handled_Statement_Sequence (gnat_node))); - gnat_poplevel (); - gnu_result = end_stmt_group (); + /* The only way to enter the block is to fall through to it. */ + if (stmt_group_may_fallthru ()) + { + start_stmt_group (); + gnat_pushlevel (); + process_decls (Declarations (gnat_node), Empty, Empty, true, true); + add_stmt (gnat_to_gnu (Handled_Statement_Sequence (gnat_node))); + gnat_poplevel (); + gnu_result = end_stmt_group (); + } + else + gnu_result = alloc_stmt_list (); break; case N_Exit_Statement: @@ -7240,6 +7247,17 @@ end_stmt_group (void) return gnu_retval; } +/* Return whether the current statement group may fall through. */ + +static inline bool +stmt_group_may_fallthru (void) +{ + if (current_stmt_group->stmt_list) + return block_may_fallthru (current_stmt_group->stmt_list); + else + return true; +} + /* Add a list of statements from GNAT_LIST, a possibly-empty list of statements.*/