[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: RFC: propagate the indentation of the actions
From: |
Akim Demaille |
Subject: |
Re: RFC: propagate the indentation of the actions |
Date: |
Sun, 30 Jun 2019 20:15:33 +0200 |
> Le 30 juin 2019 à 16:41, Akim Demaille <address@hidden> a écrit :
>
> Hi Paul,
>
> This series of patches implement both the indentation of the output,
> and the splitting after $n/@n to try to maintain comparable columns.
> WDYT?
Well, we have a problem: when $$ and the like are passed to a macro,
we get (this is GCC):
> 186. conflicts.at:607: testing parse.error=verbose and consistent errors: ...
> ../../tests/conflicts.at:607: bison --color=no -fno-caret -o input.c input.y
> ../../tests/conflicts.at:607: $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input
> input.c $LIBS
> stderr:
> input.y: In function 'yyparse':
> input.y:57:1: error: embedding a directive within macro arguments is not
> portable [-Werror]
>
> ^
Obviously, GCC does not like to see #line in the middle of a macro
invocation, and Clang neither: all the tests fail on GNU/Linux:
https://travis-ci.org/akimd/bison/builds/552422851
With Clang (https://travis-ci.org/akimd/bison/jobs/552422863):
> 186. conflicts.at:607: testing parse.error=verbose and consistent errors: ...
> ../../tests/conflicts.at:607: bison --color=no -fno-caret -o input.c input.y
> ../../tests/conflicts.at:607: $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input
> input.c $LIBS
> stderr:
> input.y:57:2: error: embedding a directive within macro arguments has
> undefined behavior [-Werror,-Wembedded-directive]
> #line 56 "input.y"
> ^
On MacOS, there is no such failure with either compiler. I guess
that the c preprocessor differs on both architecture, but is
consistently the same on each architecture.
Apparently some compilers break on using #line in macro calls.
https://stackoverflow.com/questions/28343501/is-it-legal-to-use-the-line-directive-in-a-macro-argument
I'm not too eager to introduce different types of %line support,
so I guess we should drop this idea. At least for C/C++.
Which is disappointing: using macros is allowed, but not the typical
case :(