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]

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" } */
 


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