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]

Re: [PATCH C] Fix PR37724


On 06/08/2010 09:26 AM, Andrew Pinski wrote:
On Mon, May 31, 2010 at 2:56 AM, Shujing Zhao <pearly.zhao@oracle.com> wrote:
2010-05-31 Andrew Pinski <andrew.pinski@caviumnetworks.com>

One Comment before you commit this, please use pinskia@gmail.com as the patch was written while I was at Sony rather than while I was at Cavium.

Thanks,
Andrew Pinski
Committed to trunk at revision 160418.

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 160417)
+++ ChangeLog	(revision 160418)
@@ -1,6 +1,19 @@
+2010-06-08  Andrew Pinski <pinskia@gmail.com>
+	    Shujing Zhao  <pearly.zhao@oracle.com>
+
+	PR c/37724
+	* c-typeck.c (convert_for_assignment): Call pedwarn_init if the
+	implicit bad conversions is initialization.
+	(error_init): Use gmsgid instead of msgid for argument name and change
+	the call for error.
+	(pedwarn_init): Use gmsgid instead of msgid for argument name and
+	change the call for pedwarn.
+	(warning_init): Use gmsgid instead of msgid for argument name and
+	change the call for warning.
+
 2010-06-07  Nathan Froyd  <froydnj@codesourcery.com>
 
-        * config/mips/mips-protos.h (mips_print_operand): Delete.
+	* config/mips/mips-protos.h (mips_print_operand): Delete.
 	(mips_print_operand_address): Delete.
 	* config/mips/mips.h (mips_print_operand_punct): Delete.
 	(PRINT_OPERAND): Delete.
Index: testsuite/ChangeLog
===================================================================
--- testsuite/ChangeLog	(revision 160417)
+++ testsuite/ChangeLog	(revision 160418)
@@ -1,3 +1,11 @@
+2010-06-08  Andrew Pinski <pinskia@gmail.com>
+	    Shujing Zhao  <pearly.zhao@oracle.com>
+	
+	PR c/37724
+	* gcc.dg/c90-const-expr-10.c: Adjust.
+	* gcc.dg/c99-const-expr-10.c: Adjust.
+	* gcc.dg/init-bad-7.c: New.
+
 2010-06-07  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
 	* lib/target-supports.exp (check_effective_target_gas): New proc.
Index: c-typeck.c
===================================================================
--- c-typeck.c	(revision 160417)
+++ c-typeck.c	(revision 160418)
@@ -5011,7 +5011,7 @@ convert_for_assignment (location_t locat
         pedwarn (LOCATION, OPT, AS);                                     \
         break;                                                           \
       case ic_init:                                                      \
-        pedwarn (LOCATION, OPT, IN);                                     \
+        pedwarn_init (LOCATION, OPT, IN);                                \
         break;                                                           \
       case ic_return:                                                    \
         pedwarn (LOCATION, OPT, RE);                                 	 \
@@ -5785,15 +5785,16 @@ print_spelling (char *buffer)
 }
 
 /* Issue an error message for a bad initializer component.
-   MSGID identifies the message.
+   GMSGID identifies the message.
    The component name is taken from the spelling stack.  */
 
 void
-error_init (const char *msgid)
+error_init (const char *gmsgid)
 {
   char *ofwhat;
 
-  error ("%s", _(msgid));
+  /* The gmsgid may be a format string with %< and %>. */
+  error (gmsgid);
   ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
   if (*ofwhat)
     error ("(near initialization for %qs)", ofwhat);
@@ -5801,15 +5802,16 @@ error_init (const char *msgid)
 
 /* Issue a pedantic warning for a bad initializer component.  OPT is
    the option OPT_* (from options.h) controlling this warning or 0 if
-   it is unconditionally given.  MSGID identifies the message.  The
+   it is unconditionally given.  GMSGID identifies the message.  The
    component name is taken from the spelling stack.  */
 
 void
-pedwarn_init (location_t location, int opt, const char *msgid)
+pedwarn_init (location_t location, int opt, const char *gmsgid)
 {
   char *ofwhat;
-
-  pedwarn (location, opt, "%s", _(msgid));
+  
+  /* The gmsgid may be a format string with %< and %>. */
+  pedwarn (location, opt, gmsgid);
   ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
   if (*ofwhat)
     pedwarn (location, opt, "(near initialization for %qs)", ofwhat);
@@ -5818,15 +5820,16 @@ pedwarn_init (location_t location, int o
 /* Issue a warning for a bad initializer component.
 
    OPT is the OPT_W* value corresponding to the warning option that
-   controls this warning.  MSGID identifies the message.  The
+   controls this warning.  GMSGID identifies the message.  The
    component name is taken from the spelling stack.  */
 
 static void
-warning_init (int opt, const char *msgid)
+warning_init (int opt, const char *gmsgid)
 {
   char *ofwhat;
 
-  warning (opt, "%s", _(msgid));
+  /* The gmsgid may be a format string with %< and %>. */
+  warning (opt, gmsgid);
   ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
   if (*ofwhat)
     warning (opt, "(near initialization for %qs)", ofwhat);
Index: testsuite/gcc.dg/c90-const-expr-10.c
===================================================================
--- testsuite/gcc.dg/c90-const-expr-10.c	(revision 160417)
+++ testsuite/gcc.dg/c90-const-expr-10.c	(revision 160418)
@@ -8,7 +8,7 @@
 __extension__ typedef __SIZE_TYPE__ size_t;
 
 void *p = (size_t)(void *)0; /* { dg-error "without a cast" } */
-struct s { void *a; } q = { (size_t)(void *)0 }; /* { dg-error "without a cast" } */
+struct s { void *a; } q = { (size_t)(void *)0 }; /* { dg-error "without a cast|near initialization" } */
 void *
 f (void)
 {
Index: testsuite/gcc.dg/c99-const-expr-10.c
===================================================================
--- testsuite/gcc.dg/c99-const-expr-10.c	(revision 160417)
+++ testsuite/gcc.dg/c99-const-expr-10.c	(revision 160418)
@@ -6,7 +6,7 @@
 /* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
 
 void *p = (__SIZE_TYPE__)(void *)0; /* { dg-error "without a cast" } */
-struct s { void *a; } q = { (__SIZE_TYPE__)(void *)0 }; /* { dg-error "without a cast" } */
+struct s { void *a; } q = { (__SIZE_TYPE__)(void *)0 }; /* { dg-error "without a cast|near initialization" } */
 void *
 f (void)
 {
Index: testsuite/gcc.dg/init-bad-7.c
===================================================================
--- testsuite/gcc.dg/init-bad-7.c	(revision 0)
+++ testsuite/gcc.dg/init-bad-7.c	(revision 160418)
@@ -0,0 +1,11 @@
+/* PR c/37724 */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -pedantic" } */
+
+struct f
+{
+  int *a;
+};
+
+char b[10];
+struct f g = {b}; /* { dg-warning "initialization from incompatible pointer type|near initialization for" } */

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