]> git.saurik.com Git - bison.git/commitdiff
* data/c.m4 (b4_c_function_def): Look at __STDC_VERSION__ as well
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 11 Oct 2005 05:36:04 +0000 (05:36 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 11 Oct 2005 05:36:04 +0000 (05:36 +0000)
as __STDC__, as IBM cc defines the former but not the latter.
* data/yacc.c (YYMODERN_C): New macro, which also looks at
__STDC_VERSION__.  Use it everywhere instead of looking at
__STDC__ and __cplusplus.

ChangeLog
data/c.m4
data/yacc.c

index 2cef5302bf27f227adb377d69e3cf896807d0b12..f408cab58059c57388a72e87ff6bc18edee827f7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,11 @@
        * src/scan-gram.l (gram_wrap): Redefine to avoid bug in flex 2.5.31
        that xlc complains about.
        * src/scan-skel.l (skel_wrap): Likewise.
+       * data/c.m4 (b4_c_function_def): Look at __STDC_VERSION__ as well
+       as __STDC__, as IBM cc defines the former but not the latter.
+       * data/yacc.c (YYMODERN_C): New macro, which also looks at
+       __STDC_VERSION__.  Use it everywhere instead of looking at
+       __STDC__ and __cplusplus.
 
 2005-10-10  Akim Demaille  <akim@epita.fr>
 
index 604ad1386608be8333d74e2f9a092e6928682539..c2d501923f5a1415a2bb0c8d47dd39d4f330d0f3 100644 (file)
--- a/data/c.m4
+++ b/data/c.m4
@@ -232,7 +232,7 @@ m4_define([b4_token_enums_defines],
 # ----------------------------------------------------------
 # Declare the function NAME.
 m4_define([b4_c_function_def],
-[#if defined (__STDC__) || defined (__cplusplus)
+[#if defined (__STDC__) || defined (__STDC_VERSION__) || defined (__cplusplus)
 b4_c_ansi_function_def($@)
 #else
 $2
index 1a141108659772fd7e62f2f3344843e7e80b1423..b0d051e2058325a8c5c4b7b5db143fcda23b5d89 100644 (file)
@@ -219,12 +219,23 @@ typedef struct YYLTYPE
 /* Line __line__ of yacc.c.  */
 b4_syncline([@oline@], [@ofile@])[
 
+/* Define YYMODERN_C if this compiler supports C89 or better.  Some
+   modern compilers (e.g., IBM xlc 7.0) don't define __STDC__ for
+   pedantic reasons, but they define __STDC_VERSION__ so check that
+   as well.  Consider a C++ compiler to be modern if it defines
+   __cplusplus.  */
+#if defined (__STDC__) || defined (__STDC_VERSION__) || defined (__cplusplus)
+# define YYMODERN_C 1
+#else
+# define YYMODERN_C 0
+#endif
+
 #ifndef YYSIZE_T
 # if defined (__SIZE_TYPE__)
 #  define YYSIZE_T __SIZE_TYPE__
 # elif defined (size_t)
 #  define YYSIZE_T size_t
-# elif ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
+# elif ! defined (YYSIZE_T) && YYMODERN_C
 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
 #  define YYSIZE_T size_t
 # else
@@ -266,8 +277,7 @@ b4_syncline([@oline@], [@ofile@])[
 #    define alloca _alloca
 #   else
 #    define YYSTACK_ALLOC alloca
-#    if (! defined (_ALLOCA_H) && ! defined (_STDLIB_H) \
-        && (defined (__STDC__) || defined (__cplusplus)))
+#    if ! defined (_ALLOCA_H) && ! defined (_STDLIB_H) && YYMODERN_C
 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
 #     ifndef _STDLIB_H
 #      define _STDLIB_H 1
@@ -298,15 +308,13 @@ extern "C" {
 #  endif
 #  ifndef YYMALLOC
 #   define YYMALLOC malloc
-#   if (! defined (malloc) && ! defined (_STDLIB_H) \
-       && (defined (__STDC__) || defined (__cplusplus)))
+#   if ! defined (malloc) && ! defined (_STDLIB_H) && YYMODERN_C
 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
 #   endif
 #  endif
 #  ifndef YYFREE
 #   define YYFREE free
-#   if (! defined (free) && ! defined (_STDLIB_H) \
-       && (defined (__STDC__) || defined (__cplusplus)))
+#   if ! defined (free) && ! defined (_STDLIB_H)  && YYMODERN_C
 void free (void *); /* INFRINGES ON USER NAME SPACE */
 #   endif
 #  endif
@@ -380,7 +388,7 @@ union yyalloc
 
 #endif
 
-#if defined (__STDC__) || defined (__cplusplus)
+#if YYMODERN_C
    typedef signed char yysigned_char;
 #else
    typedef short int yysigned_char;
@@ -711,7 +719,7 @@ int yydebug;
 #  else
 /* Return the length of YYSTR.  */
 static YYSIZE_T
-#   if defined (__STDC__) || defined (__cplusplus)
+#   if YYMODERN_C
 yystrlen (const char *yystr)
 #   else
 yystrlen (yystr)
@@ -735,7 +743,7 @@ yystrlen (yystr)
 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
    YYDEST.  */
 static char *
-#   if defined (__STDC__) || defined (__cplusplus)
+#   if YYMODERN_C
 yystpcpy (char *yydest, const char *yysrc)
 #   else
 yystpcpy (yydest, yysrc)
@@ -921,7 +929,7 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
 /* Prevent warnings from -Wmissing-prototypes.  */
 
 #ifdef YYPARSE_PARAM
-# if defined (__STDC__) || defined (__cplusplus)
+# if YYMODERN_C
 int yyparse (void *YYPARSE_PARAM);
 # else
 int yyparse ();
@@ -959,7 +967,7 @@ b4_pure_if([],
 `----------*/
 
 #ifdef YYPARSE_PARAM
-# if defined (__STDC__) || defined (__cplusplus)
+# if YYMODERN_C
 int yyparse (void *YYPARSE_PARAM)
 # else
 int yyparse (YYPARSE_PARAM)