From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 65966 invoked by alias); 7 Mar 2018 00:13:45 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 65954 invoked by uid 89); 7 Mar 2018 00:13:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 07 Mar 2018 00:13:42 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E62A884221 for ; Wed, 7 Mar 2018 00:13:37 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-204-35.brq.redhat.com [10.40.204.35]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0203110FFE6D for ; Wed, 7 Mar 2018 00:13:34 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id w26Kpw8v014162; Tue, 6 Mar 2018 21:51:59 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id w26KpvMV014161; Tue, 6 Mar 2018 21:51:57 +0100 Date: Wed, 07 Mar 2018 00:13:00 -0000 From: Jakub Jelinek To: "Joseph S. Myers" , Marek Polacek , Alexandre Oliva Cc: gcc-patches@gcc.gnu.org Subject: [C PATCH] Fix statement frontiers handling in the C FE (PR c/84721) Message-ID: <20180306205157.GB5867@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.1 (2017-09-22) X-IsSubscribed: yes X-SW-Source: 2018-03/txt/msg00292.txt.bz2 Hi! The C FE in multiple spots checks building_stmt_list_p () to decide if we are inside of parsing of functions or outside of that. Unfortunately, that breaks with add_debug_begin_stmt which pushes DEBUG_BEGIN_STMTs regardless of the scope it appears in; e.g. on the testcase below it pushes DEBUG_BEGIN_STMT already for the int a declaration in column 1 on line 5, and so with -g building_stmt_list_p () is pretty much always true. Fixed by only pushing DEBUG_BEGIN_STMTs when the building_stmt_list_p () predicate is true, they aren't really useful outside of functions anyway. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2018-03-06 Jakub Jelinek PR c/84721 * c-parser.c (add_debug_begin_stmt): Don't add DEBUG_BEGIN_STMT if !building_stmt_list_p (). * gcc.dg/pr84721.c: New test. --- gcc/c/c-parser.c.jj 2018-02-06 13:12:49.320804579 +0100 +++ gcc/c/c-parser.c 2018-03-06 10:56:54.207194189 +0100 @@ -1654,7 +1654,8 @@ static void c_finish_oacc_routine (struc static void add_debug_begin_stmt (location_t loc) { - if (!MAY_HAVE_DEBUG_MARKER_STMTS) + /* Don't add DEBUG_BEGIN_STMTs outside of functions, see PR84721. */ + if (!MAY_HAVE_DEBUG_MARKER_STMTS || !building_stmt_list_p ()) return; tree stmt = build0 (DEBUG_BEGIN_STMT, void_type_node); --- gcc/testsuite/gcc.dg/pr84721.c.jj 2018-03-06 11:03:23.798005268 +0100 +++ gcc/testsuite/gcc.dg/pr84721.c 2018-03-06 11:02:59.741016937 +0100 @@ -0,0 +1,6 @@ +/* PR c/84721 */ +/* { dg-do compile } */ +/* { dg-options "-g -O2" } */ + +int a[({ int b })]; /* { dg-error "braced-group within expression allowed only inside a function" } */ +int c[({ int d () {}; })]; /* { dg-error "braced-group within expression allowed only inside a function" } */ Jakub