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]

more C99 support


I have appended a little patch which adds a bit more ISO C99 support.
It only deals with the print/scanf format string parsing.  One new
modifier is supported ('z') and in the places where I previously added
comments about 'disable this warning for ISO C99'.  Now that we have a
flag for ISO C99 we can do this.

Hopefully the only controversity is the way I modified the C++
version.  Since there we have no variable to signal the use of C99 I
added it.  This seems to be cleaner than adding #ifdefs.  Besides, we
might want to add warnings when using some of the C99 features which
are not in ISO C++.

If somebody could approve it I can check the patch in myself.

-- 
---------------.      drepper at gnu.org  ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com   `------------------------

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Index: c-common.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-common.c,v
retrieving revision 1.79
diff -u -u -r1.79 c-common.c
--- c-common.c	1999/12/10 04:26:05	1.79
+++ c-common.c	1999/12/27 22:00:04
@@ -1195,7 +1195,7 @@
   /* Type of argument if length modifier `L' is used.
      If NULL, then this modifier is not allowed.  */
   tree *bigllen;
-  /* Type of argument if length modifier `Z' is used.
+  /* Type of argument if length modifiers 'z' or `Z' is used.
      If NULL, then this modifier is not allowed.  */
   tree *zlen;
   /* List of other modifier characters allowed with these options.  */
@@ -1250,7 +1250,7 @@
   { "HIMSUWdemw",	0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "-_0Ow" },
   { "Vju",		0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "-_0Oow" },
   { "Gklsz",		0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "-_0OGw" },
-  { "ABZa",		0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "^#" },
+  { "ABZza",		0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "^#" },
   { "p",		0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "#" },
   { "bh",		0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "^" },
   { "CY",		0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "-_0EOw" },
@@ -1764,26 +1764,25 @@
 		warning ("ANSI C does not support the `%c' length modifier",
 			 length_char);
 	    }
-	  else if (*format_chars == 'Z')
+	  else if (*format_chars == 'Z' || *format_chars == 'z')
 	    {
 	      length_char = *format_chars++;
-	      if (pedantic)
-		warning ("ANSI C does not support the `Z' length modifier");
+	      if (pedantic && (length_char == 'Z' || !flag_isoc9x))
+		warning ("ANSI C does not support the `%c' length modifier",
+			 length_char);
 	    }
 	  else
 	    length_char = 0;
 	  if (length_char == 'l' && *format_chars == 'l')
 	    {
 	      length_char = 'q', format_chars++;
-	      /* FIXME: Is allowed in ISO C 9x.  */
-	      if (pedantic)
+	      if (pedantic && !flag_isoc9x)
 		warning ("ANSI C does not support the `ll' length modifier");
 	    }
 	  else if (length_char == 'h' && *format_chars == 'h')
 	    {
 	      length_char = 'H', format_chars++;
-	      /* FIXME: Is allowed in ISO C 9x.  */
-	      if (pedantic)
+	      if (pedantic && !flag_isoc9x)
 		warning ("ANSI C does not support the `hh' length modifier");
 	    }
 	  if (*format_chars == 'a' && info->format_type == scanf_format_type)
@@ -1810,10 +1809,10 @@
       if (pedantic && info->format_type != strftime_format_type
 	  && (format_char == 'm' || format_char == 'C' || format_char == 'S'))
 	warning ("ANSI C does not support the `%c' format", format_char);
-      /* ??? The a and A formats are C9X extensions, and should be allowed
-	 when a C9X option is added.  */
+      /* The a and A formats are C99 extensions.  */
       if (pedantic && info->format_type != strftime_format_type
-	  && (format_char == 'a' || format_char == 'A'))
+	  && (format_char == 'a' || format_char == 'A')
+	  && !flag_isoc9x)
 	warning ("ANSI C does not support the `%c' format", format_char);
       format_chars++;
       switch (info->format_type)
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl.c,v
retrieving revision 1.524
diff -u -u -r1.524 decl.c
--- decl.c	1999/12/21 00:19:01	1.524
+++ decl.c	1999/12/27 22:00:56
@@ -319,6 +319,10 @@
 
 tree current_function_return_value;
 
+/* Nonzero means use the ISO C9x dialect of C.  */
+
+int flag_isoc9x;
+
 /* Nonzero means give `double' the same size as `float'.  */
 
 extern int flag_short_double;


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