ruby / lrama

Pure Ruby LALR parser generator
190 stars 26 forks source link

Error in initialization within YY_INITIAL_VALUE() with C++ #442

Closed matz closed 2 weeks ago

matz commented 3 months ago

In the generated C file, we see YY_INITIAL_VALUE (static YYSTYPE yyval_default;), but clang raises error error: default initialization of an object of const type. According to the C++ language specification, we need a user provided default constructor for this kind of declaration.

Changing the above line to 'YY_INITIAL_VALUE (static YYSTYPE yyval_default;)' as Bison 3.8.2 shows no error.

matz commented 2 months ago

Unfortunately

static const YYSTYPE yyval_default = YY_INITIAL_VALUE(YYSTYPE());

causes compilation error when #define YY_INITIAL_VALUE(Value) /* Nothing. */

error: expected primary-expression before ‘;’ token
 6396 | static const YYSTYPE yyval_default = YY_INITIAL_VALUE(YYSTYPE());
      |                                                                 ^