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]

some follow-up patches


- use static inline wrappers for unsigned/plain char conversion
  (suggested by Jason Merrill)
- turn off __extension__ if GCC_VERSION < 2.95; that's too
  conservative, but will definitely get people bootstrapping with 2.7
  again.
- paper over a bug causing

#if 0
^L
#endif

  to get a spurious warning.  This will be fixed properly later.

zw

	* cpphash.h: #define __extension__ away if GCC_VERSION < 2095
	(overly conservative).  Change extern inline wrappers to
	static inline, define them always, use PARAMS properly.
	* cpplex.c (_cpp_get_directive_token): Don't issue pedantic
	whitespace warnings for \f and \v at the beginning of a line.
	
===================================================================
Index: cpphash.h
--- cpphash.h	2000/05/04 04:38:00	1.46
+++ cpphash.h	2000/05/04 16:17:44
@@ -25,6 +25,13 @@ Foundation, 59 Temple Place - Suite 330,
 typedef unsigned char U_CHAR;
 #define U (const U_CHAR *)  /* Intended use: U"string" */
 
+/* gcc 2.7.2 can't handle __extension__ const char array[] = { ... }.
+   I don't know when this was added - be conservative, assume it only
+   works in 2.95.  */
+#if GCC_VERSION < 2095
+#define __extension__
+#endif
+
 /* The structure of a node in the hash table.  The hash table
    has entries for all tokens defined by #define commands (type T_MACRO),
    plus some special tokens like __LINE__ (these each have their own
@@ -257,41 +264,51 @@ extern int _cpp_handle_directive	PARAMS 
 extern void _cpp_unwind_if_stack	PARAMS ((cpp_reader *, cpp_buffer *));
 extern void _cpp_check_directive        PARAMS ((cpp_toklist *, cpp_token *));
 
-/* These are inline functions (if __GNUC__) instead of macros so we
-   can get type checking.  */
-#if GCC_VERSION >= 2007 && defined __OPTIMIZE__
-extern inline int ustrcmp (const U_CHAR *, const U_CHAR *);
-extern inline int ustrncmp (const U_CHAR *, const U_CHAR *, size_t);
-extern inline size_t ustrlen (const U_CHAR *);
-extern inline U_CHAR *uxstrdup (const U_CHAR *);
-extern inline U_CHAR *ustrchr (const U_CHAR *, int);
-
-extern inline int
-ustrcmp (const U_CHAR *s1, const U_CHAR *s2)
-{ return strcmp ((const char *)s1, (const char *)s2); }
-
-extern inline int
-ustrncmp (const U_CHAR *s1, const U_CHAR *s2, size_t n)
-{ return strncmp ((const char *)s1, (const char *)s2, n); }
-
-extern inline size_t
-ustrlen (const U_CHAR *s1)
-{ return strlen ((const char *)s1); }
-
-extern inline U_CHAR *
-uxstrdup (const U_CHAR *s1)
-{ return (U_CHAR *) xstrdup ((const char *)s1); }
-
-extern inline U_CHAR *
-ustrchr (const U_CHAR *s1, int c)
-{ return (U_CHAR *) strchr ((const char *)s1, c); }
+/* These are inline functions instead of macros so we can get type
+   checking.  */
 
-#else
-#define ustrcmp(s1_, s2_) strcmp((const char *)s1_, (const char *)s2_)
-#define ustrncmp(s1_, s2_, n_) strncmp((const char *)s1_, (const char *)s2_, n_)
-#define ustrlen(s1_) strlen((const char *)s1_)
-#define uxstrdup(s1_) (U_CHAR *) xstrdup((const char *)s1_)
-#define ustrchr(s1_, c_) (U_CHAR *) strchr((const char *)s1_, c_)
-#endif
+static inline int ustrcmp	PARAMS ((const U_CHAR *, const U_CHAR *));
+static inline int ustrncmp	PARAMS ((const U_CHAR *, const U_CHAR *,
+					 size_t));
+static inline size_t ustrlen	PARAMS ((const U_CHAR *));
+static inline U_CHAR *uxstrdup	PARAMS ((const U_CHAR *));
+static inline U_CHAR *ustrchr	PARAMS ((const U_CHAR *, int));
+
+static inline int
+ustrcmp (s1, s2)
+     const U_CHAR *s1, *s2;
+{
+  return strcmp ((const char *)s1, (const char *)s2);
+}
+
+static inline int
+ustrncmp (s1, s2, n)
+     const U_CHAR *s1, *s2;
+     size_t n;
+{
+  return strncmp ((const char *)s1, (const char *)s2, n);
+}
+
+static inline size_t
+ustrlen (s1)
+     const U_CHAR *s1;
+{
+  return strlen ((const char *)s1);
+}
+
+static inline U_CHAR *
+uxstrdup (s1)
+     const U_CHAR *s1;
+{
+  return (U_CHAR *) xstrdup ((const char *)s1);
+}
+
+static inline U_CHAR *
+ustrchr (s1, c)
+     const U_CHAR *s1;
+     int c;
+{
+  return (U_CHAR *) strchr ((const char *)s1, c);
+}
 
 #endif
===================================================================
Index: cpplex.c
--- cpplex.c	2000/05/04 04:38:00	1.35
+++ cpplex.c	2000/05/04 16:17:46
@@ -1641,8 +1641,10 @@ _cpp_get_directive_token (pfile)
 {
   long old_written;
   enum cpp_ttype token;
+  int at_bol;
 
  get_next:
+  at_bol = (CPP_BUFFER (pfile)->cur == CPP_BUFFER (pfile)->line_base);
   old_written = CPP_WRITTEN (pfile);
   token = _cpp_lex_token (pfile);
   switch (token)
@@ -1657,7 +1659,9 @@ _cpp_get_directive_token (pfile)
       return CPP_VSPACE;
 
     case CPP_HSPACE:
-      if (CPP_PEDANTIC (pfile))
+      /* The purpose of this rather strange check is to prevent pedantic
+	 warnings for ^L in an #ifdefed out block.  */
+      if (CPP_PEDANTIC (pfile) && ! at_bol)
 	pedantic_whitespace (pfile, pfile->token_buffer + old_written,
 			     CPP_WRITTEN (pfile) - old_written);
       CPP_SET_WRITTEN (pfile, old_written);

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