OSDN Git Service

PR c/24329
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 3 Nov 2005 03:30:36 +0000 (03:30 +0000)
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 3 Nov 2005 03:30:36 +0000 (03:30 +0000)
* c-pretty-print.c (pp_c_type_specifier): Do not recurse if
c_common_type_for_mode returns an unnamed type.

testsuite:
* gcc.dg/format/unnamed-1.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@106421 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-pretty-print.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/format/unnamed-1.c [new file with mode: 0644]

index a2e518a..8de34f2 100644 (file)
@@ -1,3 +1,9 @@
+2005-11-03  Joseph S. Myers  <joseph@codesourcery.com>
+
+       PR c/24329
+       * c-pretty-print.c (pp_c_type_specifier): Do not recurse if
+       c_common_type_for_mode returns an unnamed type.
+
 2005-11-02  Richard Henderson  <rth@redhat.com>
 
        PR target/9350
index bbc19be..5e67a96 100644 (file)
@@ -323,11 +323,32 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t)
        {
          int prec = TYPE_PRECISION (t);
          t = c_common_type_for_mode (TYPE_MODE (t), TYPE_UNSIGNED (t));
-         pp_c_type_specifier (pp, t);
-         if (TYPE_PRECISION (t) != prec)
+         if (TYPE_NAME (t))
+           {
+             pp_c_type_specifier (pp, t);
+             if (TYPE_PRECISION (t) != prec)
+               {
+                 pp_string (pp, ":");
+                 pp_decimal_int (pp, prec);
+               }
+           }
+         else
            {
-             pp_string (pp, ":");
+             switch (code)
+               {
+               case INTEGER_TYPE:
+                 pp_string (pp, (TYPE_UNSIGNED (t)
+                                 ? "<unnamed-unsigned:"
+                                 : "<unnamed-signed:"));
+                 break;
+               case REAL_TYPE:
+                 pp_string (pp, "<unnamed-float:");
+                 break;
+               default:
+                 gcc_unreachable ();
+               }
              pp_decimal_int (pp, prec);
+             pp_string (pp, ">");
            }
        }
       break;
index b52603b..3934527 100644 (file)
@@ -1,3 +1,8 @@
+2005-11-03  Joseph S. Myers  <joseph@codesourcery.com>
+
+       PR c/24329
+       * gcc.dg/format/unnamed-1.c: New test.
+
 2005-11-02  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/22434
diff --git a/gcc/testsuite/gcc.dg/format/unnamed-1.c b/gcc/testsuite/gcc.dg/format/unnamed-1.c
new file mode 100644 (file)
index 0000000..5fc11a1
--- /dev/null
@@ -0,0 +1,22 @@
+/* Test for warnings with possibly unnamed integer types.  Bug 24329.  */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-Wformat" } */
+
+#include "format.h"
+
+/* Definition of TItype follows same logic as in gcc.dg/titype-1.c,
+   but must be a #define to avoid giving the type a name.  */
+#if defined(__LP64__) && !defined(__hppa__)
+#define TItype int __attribute__ ((mode (TI)))
+#else
+#define TItype long
+#endif
+
+void
+f (TItype x)
+{
+  printf("%d", x); /* { dg-warning "expects type" } */
+  printf("%d", 141592653589793238462643383279502884197169399375105820974944); /* { dg-warning "expects type" } */
+  /* { dg-warning "unsigned only|too large" "constant" { target *-*-* } 20 } */
+}