public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [C PATCH] Fix statement frontiers handling in the C FE (PR c/84721)
  2018-03-07  0:13 [C PATCH] Fix statement frontiers handling in the C FE (PR c/84721) Jakub Jelinek
@ 2018-03-06 20:55 ` Marek Polacek
  0 siblings, 0 replies; 2+ messages in thread
From: Marek Polacek @ 2018-03-06 20:55 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Joseph S. Myers, Alexandre Oliva, gcc-patches

On Tue, Mar 06, 2018 at 09:51:57PM +0100, Jakub Jelinek wrote:
> 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?

Ok.

	Marek

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [C PATCH] Fix statement frontiers handling in the C FE (PR c/84721)
@ 2018-03-07  0:13 Jakub Jelinek
  2018-03-06 20:55 ` Marek Polacek
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2018-03-07  0:13 UTC (permalink / raw)
  To: Joseph S. Myers, Marek Polacek, Alexandre Oliva; +Cc: gcc-patches

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  <jakub@redhat.com>

	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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-07  0:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-07  0:13 [C PATCH] Fix statement frontiers handling in the C FE (PR c/84721) Jakub Jelinek
2018-03-06 20:55 ` Marek Polacek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).