glr2.cc: call the destructor in a way that complies with clang

examples/c++/glr/c++-types.cc:721:24: error:
      expected the class name after '~' to name a destructor
    yysval.YYSTYPE::~semantic_type ();
                    ^

Using a local typedef, for some reaon, result in clang complaining
about a useless local typedef.  Since anyway we don't want to keep on
using YYSTYPE and YYLTYPE, it is time to introduce proper typedefs to
reach these guys.  And to be slightly in advance of the other
skeletons: use value_type, not semantic_type.  This is much more
consistent with our use of the (kind, value, location) triplet.

* data/skeletons/glr2.cc (glr_state::value_type)
(glr_state::location_type): New.
(glr_state::~glr_state): Use value_type to name the dtor.
This commit is contained in:
Akim Demaille
2020-12-20 18:35:51 +01:00
parent 0a82316e54
commit df34ad7c6e

View File

@@ -770,16 +770,19 @@ yyrhsLength (rule_num yyrule);
class glr_state class glr_state
{ {
public: public:
glr_state() typedef ]b4_namespace_ref[::]b4_parser_class[::semantic_type value_type;]b4_locations_if([[
: yyresolved(false) typedef ]b4_namespace_ref[::]b4_parser_class[::location_type location_type;]])[
, yylrState(0)
, yyposn(0) glr_state ()
, yypred(0)]b4_parse_assert_if([[ : yyresolved (false)
, yylrState (0)
, yyposn (0)
, yypred (0)]b4_parse_assert_if([[
, magic_ (MAGIC)]])[ , magic_ (MAGIC)]])[
{} {}
/// Build with a semantic value. /// Build with a semantic value.
glr_state (state_num lrState, size_t posn, YYSTYPE sval]b4_locations_if([[, YYLTYPE loc]])[) glr_state (state_num lrState, size_t posn, value_type sval]b4_locations_if([[, location_type loc]])[)
: yyresolved (true) : yyresolved (true)
, yylrState (lrState) , yylrState (lrState)
, yyposn (posn) , yyposn (posn)
@@ -811,7 +814,7 @@ public:
check_ (); check_ ();
magic_ = 0;]])[ magic_ = 0;]])[
if (yyresolved) if (yyresolved)
yysval.YYSTYPE::~semantic_type (); yysval.~value_type ();
} }
glr_state& operator= (const glr_state& other) glr_state& operator= (const glr_state& other)
@@ -825,7 +828,7 @@ public:
check_ (); check_ ();
other.check_ ();]])[ other.check_ ();]])[
if (!yyresolved && other.yyresolved) if (!yyresolved && other.yyresolved)
new (&yysval) YYSTYPE; new (&yysval) value_type;
yyresolved = other.yyresolved; yyresolved = other.yyresolved;
yylrState = other.yylrState; yylrState = other.yylrState;
yyposn = other.yyposn; yyposn = other.yyposn;
@@ -857,13 +860,13 @@ public:
const semantic_option* firstVal() const; const semantic_option* firstVal() const;
void setFirstVal(const semantic_option* option); void setFirstVal(const semantic_option* option);
YYSTYPE& semanticVal() value_type& semanticVal ()
{]b4_parse_assert_if([[ {]b4_parse_assert_if([[
check_ ();]])[ check_ ();]])[
return yysval; return yysval;
} }
const YYSTYPE& semanticVal() const const value_type& semanticVal () const
{]b4_parse_assert_if([[ {]b4_parse_assert_if([[
check_ ();]])[ check_ ();]])[
return yysval; return yysval;
@@ -919,12 +922,12 @@ public:
* yyfirstVal. */ * yyfirstVal. */
std::ptrdiff_t yyfirstVal; std::ptrdiff_t yyfirstVal;
/** Semantic value for this state. */ /** Semantic value for this state. */
YYSTYPE yysval; value_type yysval;
};]b4_locations_if([[ };]b4_locations_if([[
// FIXME: Why public? // FIXME: Why public?
public: public:
/** Source location for this state. */ /** Source location for this state. */
YYLTYPE yyloc;]])[ location_type yyloc;]])[
]b4_parse_assert_if([[ ]b4_parse_assert_if([[
public: public: