This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch for bug 17730


This patch fixes bug 17730, a badly formatted message from
lvalue_or_else because its argument was a literal string rather than a
format string.

This fix is temporary; I noticed one call to lvalue_or_else with a
conditional expression as the string which fails to get the contained
strings marked for translation, and readonly_error has a similar
problem but worse because it builds strings up out of pieces.  I'll
fix those next (passing around enums rather than English strings so
the whole strings are visible where the format functions are called,
and not building up sentences out of pieces).

Bootstrapped with no regressions on i686-pc-linux-gnu.  Applied to
mainline.

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
  http://www.srcf.ucam.org/~jsm28/gcc/#c90status - status of C90 for GCC 4.0
    jsm@polyomino.org.uk (personal mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)

2004-09-30  Joseph S. Myers  <jsm@polyomino.org.uk>

	PR c/17730
	* c-typeck.c (lvalue_or_else): Pass msgid directly to error.

testsuite:
2004-09-30  Joseph S. Myers  <jsm@polyomino.org.uk>

	PR c/17730
	* gcc.dg/pr17730-1.c: New test

diff -rupN GCC.orig/gcc/c-typeck.c GCC/gcc/c-typeck.c
--- GCC.orig/gcc/c-typeck.c	2004-09-27 19:31:20.000000000 +0000
+++ GCC/gcc/c-typeck.c	2004-09-30 13:16:12.000000000 +0000
@@ -2682,7 +2682,9 @@ lvalue_p (tree ref)
 }
 
 /* Return nonzero if REF is an lvalue valid for this language;
-   otherwise, print an error message and return zero.  */
+   otherwise, print an error message and return zero.  MSGID
+   is a format string which receives no arguments, but in which
+   formats such as %< and %> may occur.  */
 
 static int
 lvalue_or_else (tree ref, const char *msgid)
@@ -2690,7 +2692,7 @@ lvalue_or_else (tree ref, const char *ms
   int win = lvalue_p (ref);
 
   if (! win)
-    error ("%s", msgid);
+    error (msgid);
 
   return win;
 }
diff -rupN GCC.orig/gcc/testsuite/gcc.dg/pr17730-1.c GCC/gcc/testsuite/gcc.dg/pr17730-1.c
--- GCC.orig/gcc/testsuite/gcc.dg/pr17730-1.c	1970-01-01 00:00:00.000000000 +0000
+++ GCC/gcc/testsuite/gcc.dg/pr17730-1.c	2004-09-30 13:05:58.000000000 +0000
@@ -0,0 +1,5 @@
+/* Test formatting of message for invalid lvalue.  Bug 17730.  */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+char *p = &'C'; /* { dg-error "error: invalid lvalue in unary '&'" } */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]