> On 16 Oct 2018, at 13:19, Akim Demaille <a...@lrde.epita.fr> wrote:
> 
>> Le 16 oct. 2018 à 11:20, Hans Åberg <haber...@telia.com> 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;
}
--


Reply via email to