bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bison, yystpcpy, yystrlen


From: Paul Eggert
Subject: Re: Bison, yystpcpy, yystrlen
Date: Tue, 4 Dec 2001 05:43:07 -0800 (PST)

> From: Akim Demaille <address@hidden>
> Date: 30 Nov 2001 15:40:36 +0100
> 
> When running the test suite in paranoid mode (./configure
> --enable-gcc-warnings), there is a problem in the parsers....
> 
> The problem is that the static functions yystpcpy etc., which are used
> if not found on the system, are not defined in ANSI.  Therefore, even
> though they are static, GCC warns since they have not been declared.

When I tried it, the problem was just in yystpcpy; the other functions
were OK.  That is because of a typo: the other functions inspected
both __cplusplus and __STDC__, but yystpcpy inspected just __cplusplus.
Sorry about that.

Also, I ran into a warning with GCC 3.0.2 on sparc Solaris about the
assignment of char * to a type that is more strictly aligned.  Hmm, I
wonder why you didn't see that one?

Anyway, I installed the following patch (on the trunk as well).

2001-12-04  Paul Eggert  <address@hidden>

        * src/bison.simple (YYPOINTER): New macro.
        (YYSTACK_RELOCATE): Use it to avoid a GCC warning.
        (yystpcpy): Use prototype if __STDC__ is defined, not just
        if __cplusplus is defined.
        
--- bison.simple        2001/11/30 13:14:10     1.53.2.10
+++ bison.simple        2001/12/04 13:28:18     1.53.2.11
@@ -103,4 +103,10 @@ union yyalloc
 # endif
 
+# if defined (__STDC__) || defined (__cplusplus)
+#  define YYPOINTER void *
+# else
+#  define YYPOINTER char *
+# endif
+
 /* Relocate the TYPE STACK from its old location to the new one.  The
    local variables YYSIZE and YYSTACKSIZE give the old and new number of
@@ -114,5 +120,5 @@ union yyalloc
        yymemcpy (yyptr, (char *) (Stack),                              \
                  yysize * (YYSIZE_T) sizeof (Type));                   \
-       (Stack) = (Type *) yyptr;                                       \
+       (Stack) = (Type *) (YYPOINTER) yyptr;                           \
        yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX;     \
        yynewbytes -= yynewbytes % sizeof (union yyalloc);              \
@@ -302,10 +308,10 @@ yystrlen (yystr)
    YYDEST.  */
 static char *
-#   ifndef __cplusplus
+#   if defined (__STDC__) || defined (__cplusplus)
+yystpcpy (char *yydest, const char *yysrc)
+#   else
 yystpcpy (yydest, yysrc)
      char *yydest;
      const char *yysrc;
-#   else
-yystpcpy (char *yydest, const char *yysrc)
 #   endif
 {
@@ -798,5 +804,5 @@ yyerrlab:
        }
       else
-#endif /* YYERROR_VERBOSE */
+#endif /* defined (YYERROR_VERBOSE) */
        yyerror ("parse error");
     }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]