diff mbox

[C] Handle C_MAYBE_CONST_EXPR in diagnostic (PR c/45079)

Message ID 20100727065611.GR18378@tyan-ft48-01.lab.bos.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek July 27, 2010, 6:56 a.m. UTC
Hi!

As the testcase below shows, C_MAYBE_CONST_EXPR isn't handled by
pp_c_expression.  The following patch fixes that.

Bootstrapped/regtested on x86_64-linux and i686-linux.  Ok for trunk/4.5?

2010-07-27  Jakub Jelinek  <jakub@redhat.com>

	PR c/45079
	* c-pretty-print.c (pp_c_expression): Handle C_MAYBE_CONST_EXPR.

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


	Jakub

Comments

Joseph Myers July 27, 2010, 10:07 a.m. UTC | #1
On Tue, 27 Jul 2010, Jakub Jelinek wrote:

> Hi!
> 
> As the testcase below shows, C_MAYBE_CONST_EXPR isn't handled by
> pp_c_expression.  The following patch fixes that.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux.  Ok for trunk/4.5?
> 
> 2010-07-27  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR c/45079
> 	* c-pretty-print.c (pp_c_expression): Handle C_MAYBE_CONST_EXPR.
> 
> 	* gcc.dg/pr45079.c: New test.

OK.
diff mbox

Patch

--- gcc/c-family/c-pretty-print.c.jj	2010-06-07 11:24:57.000000000 +0200
+++ gcc/c-family/c-pretty-print.c	2010-07-26 16:41:12.000000000 +0200
@@ -2167,6 +2167,10 @@  pp_c_expression (c_pretty_printer *pp, t
       pp_string (pp, "({...})");
       break;
 
+    case C_MAYBE_CONST_EXPR:
+      pp_c_expression (pp, C_MAYBE_CONST_EXPR_EXPR (e));
+      break;
+
     default:
       pp_unsupported_tree (pp, e);
       break;
--- gcc/testsuite/gcc.dg/pr45079.c.jj	2010-07-26 16:44:37.000000000 +0200
+++ gcc/testsuite/gcc.dg/pr45079.c	2010-07-26 16:44:19.000000000 +0200
@@ -0,0 +1,10 @@ 
+/* PR c/45079 */
+/* { dg-do compile } */
+
+void
+foo (const char *p, int cond, int a, int b)
+{
+  p[cond ? a : b] = '\0';	/* { dg-error "assignment of read-only location" } */
+}
+
+/* { dg-bogus "not supported by" "" { target *-*-* } 0 } */