[Top][All Lists]

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

error: expected primary-expression before "__attribute__" when compiling

Subject: error: expected primary-expression before "__attribute__" when compiling a c++ generated file
Date: Wed, 17 Oct 2007 10:54:04 +0200


I'am trying to compile a source file generated by bison (I tried 1.875
and 2.3) on Solaris 2.10 with the command :

bison -y -d /users/kscope/src/kscope-1.5.2/src/dotparse.ypp

When I compile the resulting file (dotparse.cpp), I get the following
error :

g++ -DHAVE_CONFIG_H -I. -I.. -I/users/kscope/bin/kde/include
-I/users/kscope/bin/qt/include    -DQT_THREAD_SUPPORT  -D_REENTRANT
-Wall -W -Wpointer-arith -O2 -Wno-non-virtual-dtor -fno-exceptions
-fno-check-new -fno-common  -MT dotparse.o -MD -MP -MF
.deps/dotparse.Tpo -c -o dotparse.o dotparse.cpp
y.tab.c:147:6: warning: "YYSTACK_USE_ALLOCA" is not defined
y.tab.c:640:5: warning: "YYMAXDEPTH" is not defined
y.tab.c: In function `int yyparse()':
y.tab.c:1306: error: expected primary-expression before "__attribute__"
y.tab.c:1306: error: expected `;' before "__attribute__"
y.tab.c:1301: warning: label `yyerrlab1' defined but not used
gmake[3]: *** [dotparse.o] Error 1
gmake[3]: Leaving directory `/users/kscope/src/kscope-1.5.2/src'
gmake[2]: *** [all] Error 2
gmake[2]: Leaving directory `/users/kscope/src/kscope-1.5.2/src'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/users/kscope/src/kscope-1.5.2'
gmake: *** [all] Error 2

And actually, instead of suppressing a warning, the "#if defined ..."
sequence seems to add an error.

| yyerrlab1 -- error raised explicitly by an action.  |

  /* Suppress GCC warning that yyerrlab1 is unused when no action
     invokes YYERROR.  */
#if defined (__GNUC_MINOR__) && 2093 <= (__GNUC__ * 1000 +
  __attribute__ ((__unused__))

This only happens on Solaris.
The same source generated on Linux RHEL4 gives a label completely
different :

| yyerrlab1 -- common code for both syntax error and YYERROR.  |
  yyerrstatus = 3;      /* Each real token shifted decrements this.  */

  for (;;)
      yyn = yypact[yystate];
      if (yyn != YYPACT_NINF)
          yyn += YYTERROR;
          if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
              yyn = yytable[yyn];
              if (0 < yyn)

      /* Pop the current state because it cannot handle the error token.
      if (yyssp == yyss)

      YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
      yydestruct (yystos[yystate], yyvsp);
      yystate = *yyssp;
      YY_STACK_PRINT (yyss, yyssp);

  if (yyn == YYFINAL)

  YYDPRINTF ((stderr, "Shifting error token, "));

  *++yyvsp = yylval;

  yystate = yyn;
  goto yynewstate;

Any idea about this ?


reply via email to

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