re PR c/24329 (segfault with -Wall and long integer literal)
PR c/24329 * 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. From-SVN: r106421
This commit is contained in:
parent
150cdc9e16
commit
a92c58c273
4 changed files with 57 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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_string (pp, ":");
|
||||
pp_c_type_specifier (pp, t);
|
||||
if (TYPE_PRECISION (t) != prec)
|
||||
{
|
||||
pp_string (pp, ":");
|
||||
pp_decimal_int (pp, prec);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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;
|
||||
|
|
|
@ -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
|
||||
|
|
22
gcc/testsuite/gcc.dg/format/unnamed-1.c
Normal file
22
gcc/testsuite/gcc.dg/format/unnamed-1.c
Normal file
|
@ -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 } */
|
||||
}
|
Loading…
Add table
Reference in a new issue