Patch for %Lg format pedantic warning (PR c/83)

Joseph S. Myers jsm28@cam.ac.uk
Sat Jul 8 19:27:00 GMT 2000


This patch fixes the problem (PR c/83) where GCC objects to printf
formats such as "%Lg" in pedantic mode, although these are valid C89
and C99 formats for long double arguments.  The warnings for 'q' and
for 'L' used on integer arguments are retained.

No testcase is added by this patch, since I have a thorough testcase
covering most of the format checking involving use and misuse of C89
printf features nearly ready.

C compiler bootstrapped and C testsuite run on i686-pc-linux-gnu; no
regressions.

2000-07-09  Joseph S. Myers  <jsm28@cam.ac.uk>

	* c-common.c (check_format_info): Do not make a pedantic objection
	to the 'L' length modifier if used with a floating point type
	character.

--- c-common.c	Sat Jul  8 16:23:56 2000
+++ c-common.c.new	Sun Jul  9 00:09:20 2000
@@ -1775,7 +1775,7 @@
 	  else if (*format_chars == 'q' || *format_chars == 'L')
 	    {
 	      length_char = *format_chars++;
-	      if (pedantic)
+	      if (length_char == 'q' && pedantic)
 		warning ("ANSI C does not support the `%c' length modifier",
 			 length_char);
 	    }
@@ -1931,6 +1931,13 @@
       if (wanted_type == 0)
 	warning ("use of `%c' length character with `%c' type character",
 		 length_char, format_char);
+      else if (length_char == 'L' && pedantic
+	       && !(format_char == 'a' || format_char == 'A'
+		    || format_char == 'e' || format_char == 'E'
+		    || format_char == 'f' || format_char == 'F'
+		    || format_char == 'g' || format_char == 'G'))
+	warning ("ANSI C does not support the `L' length modifier with the `%c' type character",
+		 format_char);
 
       /* Finally. . .check type of argument against desired type!  */
       if (info->first_arg_num == 0)

-- 
Joseph S. Myers
jsm28@cam.ac.uk



More information about the Gcc-patches mailing list