[PATCH] Handle GOTO_EXPR in C pretty-printing (PR c/35742)

Jakub Jelinek jakub@redhat.com
Fri Jan 9 13:37:00 GMT 2009


Hi!

As we can't figure out whether GOTO_EXPR is a break, goto, continue, etc.,
before caret diagnostics is introduced it is IMHO best to be handled like
BIND_EXPR.

Bootstrapped/regtested on {x86_64,i686}-linux.  Ok for trunk?

2009-01-09  Jakub Jelinek  <jakub@redhat.com>

	PR c/35742
	* c-pretty-print.c (pp_c_expression): Handle GOTO_EXPR like
	BIND_EXPR.

	* gcc.dg/pr35742.c: New test.

--- gcc/c-pretty-print.c.jj	2008-12-08 20:44:43.000000000 +0100
+++ gcc/c-pretty-print.c	2009-01-09 12:04:17.000000000 +0100
@@ -1,5 +1,5 @@
 /* Subroutines common to both C and C++ pretty-printers.
-   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008
+   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
    Free Software Foundation, Inc.
    Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
 
@@ -2104,6 +2104,7 @@ pp_c_expression (c_pretty_printer *pp, t
       break;
 
     case BIND_EXPR:
+    case GOTO_EXPR:
       /* We don't yet have a way of dumping statements in a
          human-readable format.  */
       pp_string (pp, "({...})");
--- gcc/testsuite/gcc.dg/pr35742.c.jj	2009-01-09 12:07:59.000000000 +0100
+++ gcc/testsuite/gcc.dg/pr35742.c	2009-01-09 12:10:11.000000000 +0100
@@ -0,0 +1,13 @@
+/* PR c/35742 */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
+/* { dg-bogus "not supported by" "" { target *-*-* } 0 } */
+
+void
+foo ()
+{
+  for (;;)
+    ({break;})();	/* { dg-error "is not a function" } */
+  for (;;)
+    ({continue;})();	/* { dg-error "is not a function" } */
+}

	Jakub



More information about the Gcc-patches mailing list