This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch to reject '*' from __asm_fprintf__ format checking
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Cc: jsm28 at cam dot ac dot uk
- Date: Wed, 11 Jun 2003 13:04:08 -0400 (EDT)
- Subject: Patch to reject '*' from __asm_fprintf__ format checking
Turns out, final.c:asm_fprintf() accepts hard values for width and
precision but not asterisk '*'. This patch updates the
__asm_fprintf__ format attribute to account for this.
(Thanks to Joseph for explaining how to do it.)
I verified this by hand on the testcase, but my main bootstrap
platforms are hosed on mainline right now so I haven't done the full
testing cycle. Once I get that done, ok to install?
Thanks,
--Kaveh
2003-06-11 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
gcc:
* c-format.c (format_types_orig): Disallow '*' width/precision in
asm_fprintf format checks.
testsuite:
* gcc.dg/format/asm_fprintf-1.c: Update width/precision checks.
diff -rup orig/egcc-CVS20030602/gcc/c-format.c egcc-CVS20030602/gcc/c-format.c
--- orig/egcc-CVS20030602/gcc/c-format.c 2003-06-01 21:39:16.000000000 -0400
+++ egcc-CVS20030602/gcc/c-format.c 2003-06-11 10:49:27.338737000 -0400
@@ -814,7 +814,7 @@ static const format_kind_info format_typ
asm_fprintf_flag_specs, asm_fprintf_flag_pairs,
FMT_FLAG_ARG_CONVERT|FMT_FLAG_EMPTY_PREC_OK,
'w', 0, 'p', 0, 'L',
- &integer_type_node, &integer_type_node
+ NULL, NULL
},
{ "scanf", scanf_length_specs, scan_char_table, "*'I", NULL,
scanf_flag_specs, scanf_flag_pairs,
diff -rup orig/egcc-CVS20030602/gcc/testsuite/gcc.dg/format/asm_fprintf-1.c egcc-CVS20030602/gcc/testsuite/gcc.dg/format/asm_fprintf-1.c
--- orig/egcc-CVS20030602/gcc/testsuite/gcc.dg/format/asm_fprintf-1.c 2003-06-11 10:49:19.659490000 -0400
+++ egcc-CVS20030602/gcc/testsuite/gcc.dg/format/asm_fprintf-1.c 2003-06-11 11:02:28.747654000 -0400
@@ -34,9 +34,6 @@ foo (int i, int i1, int i2, unsigned int
asm_fprintf ("%.7d\n", i);
asm_fprintf ("%+9.4d\n", i);
asm_fprintf ("%.3ld\n", l);
- asm_fprintf ("%*d\n", i1, i);
- asm_fprintf ("%.*d\n", i2, i);
- asm_fprintf ("%*.*ld\n", i1, i2, l);
asm_fprintf ("%d %lu\n", i, ul);
/* Extensions provided in asm_fprintf. */
@@ -58,8 +55,9 @@ foo (int i, int i1, int i2, unsigned int
asm_fprintf ("%d", l); /* { dg-warning "format" "bad argument types" } */
asm_fprintf ("%wd", l); /* { dg-warning "format" "bad argument types" } */
asm_fprintf ("%d", ll); /* { dg-warning "format" "bad argument types" } */
- asm_fprintf ("%*.*d", l, i2, i); /* { dg-warning "field" "bad * argument types" } */
- asm_fprintf ("%*.*d", i1, l, i); /* { dg-warning "field" "bad * argument types" } */
+ asm_fprintf ("%*d\n", i1, i); /* { dg-warning "format" "bad * argument types" } */
+ asm_fprintf ("%.*d\n", i2, i); /* { dg-warning "format" "bad * argument types" } */
+ asm_fprintf ("%*.*ld\n", i1, i2, l); /* { dg-warning "format" "bad * argument types" } */
asm_fprintf ("%ld", i); /* { dg-warning "format" "bad argument types" } */
asm_fprintf ("%s", n); /* { dg-warning "format" "bad argument types" } */