]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/37724 ("initialization from incompatible pointer type" does not say which...
authorAndrew Pinski <pinskia@gmail.com>
Tue, 8 Jun 2010 03:56:40 +0000 (03:56 +0000)
committerShujing Zhao <pzhao@gcc.gnu.org>
Tue, 8 Jun 2010 03:56:40 +0000 (03:56 +0000)
gcc/
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.

gcc/testsuite/
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.

From-SVN: r160418

gcc/ChangeLog
gcc/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/c90-const-expr-10.c
gcc/testsuite/gcc.dg/c99-const-expr-10.c
gcc/testsuite/gcc.dg/init-bad-7.c [new file with mode: 0644]

index 86791613454d9b08701f9e7b43259b2f90318903..af5337296c2466f20b8d12919da7136182784f26 100644 (file)
@@ -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 103272c2368d29b6a08071660e97efe70b429d5c..b2d3986e185f9579b166809587244e43d1fa812f 100644 (file)
@@ -5011,7 +5011,7 @@ convert_for_assignment (location_t location, tree type, tree rhs,
         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 opt, const char *msgid)
 /* 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 cfc229f4d395431ba8fc7825b2f7ef4cf51b365f..a9b9c7a9c183c3b6acef531af7064ab2c94125ba 100644 (file)
@@ -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 bad388c90b15f4f7fb5e38521d2120b529fc1129..30c60e31f90568a08d55b229020e609a873b7c98 100644 (file)
@@ -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 8e5a1043d290a1017dde33d15f1eacf0fa8597fa..2aca6106a47b65167e95ad04bb1787f56eb20f98 100644 (file)
@@ -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)
 {
diff --git a/gcc/testsuite/gcc.dg/init-bad-7.c b/gcc/testsuite/gcc.dg/init-bad-7.c
new file mode 100644 (file)
index 0000000..738ed60
--- /dev/null
@@ -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" } */