Re: Bison 3.1 api.value.type {semantic_type} error in gcc8
> On 16 Oct 2018, at 18:21, Akim Demaille wrote: > >> Le 16 oct. 2018 à 14:57, Hans Åberg a écrit : >> >> The minimal example below compiles with clang++6, but not with g++8. One >> would think that it should define a qualified name B::A, used as >> mu::B::A a; >> as in the other cases below. But I have it probably by legacy since when >> Bison used YYSTYPE only, though. > > Concretely, it is my understanding that this is irrelevant > to Bison, isn’t it? One can use templates—in the example below, B is the parser, and A the semantic type. That would be using C++ paradigms rather than writing the code directly. -- #include #include namespace mu { class A {}; template class B { public: typedef T A; }; } int main () { mu::B::A a; mu::A b; return 0; } --
Re: Bison 3.1 api.value.type {semantic_type} error in gcc8
> On 16 Oct 2018, at 18:21, Akim Demaille wrote: > >> Le 16 oct. 2018 à 14:57, Hans Åberg a écrit : >> >> The minimal example below compiles with clang++6, but not with g++8. One >> would think that it should define a qualified name B::A, used as >> mu::B::A a; >> as in the other cases below. But I have it probably by legacy since when >> Bison used YYSTYPE only, though. > > Concretely, it is my understanding that this is irrelevant > to Bison, isn’t it? It has been reported in 2011, and based on [basic.scope.class] they have decided that this is how it should be [1], though it looks as though [dcl.typedef] says differently. But too limited to worry about in Bison, I think. 1. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50418
Re: Bison 3.1 api.value.type {semantic_type} error in gcc8
> Le 16 oct. 2018 à 14:57, Hans Åberg a écrit : > > The minimal example below compiles with clang++6, but not with g++8. One > would think that it should define a qualified name B::A, used as > mu::B::A a; > as in the other cases below. But I have it probably by legacy since when > Bison used YYSTYPE only, though. Concretely, it is my understanding that this is irrelevant to Bison, isn’t it?
Re: Bison 3.1 api.value.type {semantic_type} error in gcc8
> On 16 Oct 2018, at 13:19, Akim Demaille wrote: > >> Le 16 oct. 2018 à 11:20, Hans Åberg a écrit : >> >> In Bison 3.1, >> %define api.value.type {semantic_type} > > Actually, what are you trying to achieve? semantic_type is the name > of the typedef used by bison. So, of course, it’s quite a bad idea > to use that name. Unless you do mean to use that name, but not > Bison’s, rather some other definition, coming from some other place, > in which case you must provide the namespace/path to it. The minimal example below compiles with clang++6, but not with g++8. One would think that it should define a qualified name B::A, used as mu::B::A a; as in the other cases below. But I have it probably by legacy since when Bison used YYSTYPE only, though. A draft version of the C++ standard says: 7.1.3 The typedef specifier [dcl.typedef] 4. In a given class scope, a typedef specifier can be used to redefine any class-name declared in that scope that is not also a typedef-name to refer to the type to which it already refers. [Example: struct S { typedef struct A { } A; // OK typedef struct B B; // OK typedef A A;// error }; — end example] So in the example below, g++8 accepts: typedef class A A; typedef mu::A A; -- namespace mu { class A {}; class B { public: typedef A A; }; } int main () { mu::B::A a; return 0; } --
Re: Bison 3.1 api.value.type {semantic_type} error in gcc8
> Le 16 oct. 2018 à 11:20, Hans Åberg a écrit : > > In Bison 3.1, > %define api.value.type {semantic_type} Actually, what are you trying to achieve? semantic_type is the name of the typedef used by bison. So, of course, it’s quite a bad idea to use that name. Unless you do mean to use that name, but not Bison’s, rather some other definition, coming from some other place, in which case you must provide the namespace/path to it.
Re: Bison 3.1 api.value.type {semantic_type} error in gcc8
> On 16 Oct 2018, at 12:10, Akim Demaille wrote: > > Hi Hans, Hello, >> Le 16 oct. 2018 à 11:20, Hans Åberg a écrit : >> >> In Bison 3.1, >> %define api.value.type {semantic_type} >> produces an error in gcc8, though accepted in clang6, by the parser header >> typedef >> #ifndef YYSTYPE >> /// Symbol semantic values. >> typedef semantic_type semantic_type; >> #else >> typedef YYSTYPE semantic_type; >> #endif > > Please, be more specific. Provide an input file, and the complete error from > the compiler. I just happened to discover it, so I do not know much about it yet. It may have to do with -std=c++17 on g++ 8.2.0, and I have a class semantic_type. A workaround is to make the typedef'ed name qualified: typedef ::semantic_type semantic_type; So if I change to %define api.value.type {::semantic_type} then it passes.
Re: Bison 3.1 api.value.type {semantic_type} error in gcc8
Hi Hans, > Le 16 oct. 2018 à 11:20, Hans Åberg a écrit : > > In Bison 3.1, > %define api.value.type {semantic_type} > produces an error in gcc8, though accepted in clang6, by the parser header > typedef > #ifndef YYSTYPE >/// Symbol semantic values. >typedef semantic_type semantic_type; > #else >typedef YYSTYPE semantic_type; > #endif Please, be more specific. Provide an input file, and the complete error from the compiler.
Bison 3.1 api.value.type {semantic_type} error in gcc8
In Bison 3.1, %define api.value.type {semantic_type} produces an error in gcc8, though accepted in clang6, by the parser header typedef #ifndef YYSTYPE /// Symbol semantic values. typedef semantic_type semantic_type; #else typedef YYSTYPE semantic_type; #endif