bug-bison
[Top][All Lists]
Advanced

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

Compiler Problems w/Bison 1.28 on SGI/IRIX65


From: Yair Lenga
Subject: Compiler Problems w/Bison 1.28 on SGI/IRIX65
Date: Tue, 02 Jan 2001 11:41:31 -0500

Greetings,

I was trying to upgrade my bison (from 1.25 to 1.28). I found the following two compilation problem - fixed them on my SGI. I will appreciate if you can incorporate those changes into future releases of Bison:

Thanks again,
Yair Lenga

System Info:

ybdev3:/home4/yair> uname -a
IRIX64 ybdev3 6.5 04151556 IP30

Usage of 'free' without prototype:

I traced the problem to the usage of 'alloca' through the test for 'YYSTACK_USE_ALLOCA'. The code
will include 'free' statements for yyss, yyvs and yyls (in my version of bison.simple, at lines ~370 and ~760).
Since the code does not include the header file for 'malloc' (through stdlib.h, or malloc.h). The 'free' function
does not have a prototype, and produce compiler error when compiling with strong type checking.

My workaround/solution was to change the top of the file where YYSTACK_ALLOC is defined:
#ifdef YYSTACK_USE_ALLOCA
#define YYSTACK_ALLOC alloca
#define    YYSTACK_FREE(x)
/* YL, 1/2/01 */
#define free(x)
#else
#define YYSTACK_ALLOC malloc
#define YYSTACK_FREE(x) free(x)
#endif

And to replace calls to 'free' with calls to YYSTACK_FREE.

Compiler Error:
bison -d -phyy expr.y
cc   -signed -xansi -fullwarn -g -w2 -woff 1174,1233,1552,3201  -diag_error 1164,1196 expr.tab.c

  The indicated function is declared implicitly.

              free (yyss);
              ^

cc-1498 cc: REMARK File = /usr/freeware/share/bison.simple, Line = 362
  There is no prototype for the call to free.

              free (yyvs);
              ^

cc-1196 cc: ERROR File = /usr/freeware/share/bison.simple, Line = 742
  The indicated function is declared implicitly.

        free (yyss);
        ^

Usage of 'K&R' style to define prototype:

The SGI compiler does not accept K&R style function as function prototype. My solution was to prefix the '__cplusplus' test
for yy_memcpy on line ~180, with a test for ANSI-C.

#else
#ifdef    __STDC__
static void __yy_memcpy (char *to, char *from, unsigned int count)
{
  register char *f = from;
  register char *t = to;
  register int i = count;

  while (i-- > 0)
    *t++ = *f++;
}
#endif
#else
#ifndef    __cplusplus__
...
 


reply via email to

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