hook up bison destructors for state objects

this doesn't help much yet since the state objects themselves also leak
all memory they are given.
This commit is contained in:
pennae 2024-02-11 12:09:07 +01:00
parent 8840e1e075
commit ceacc823c7

View file

@ -61,6 +61,8 @@ using namespace nix;
#define CUR_POS state->at(*yylocp) #define CUR_POS state->at(*yylocp)
// otherwise destructors cause compiler errors
#pragma GCC diagnostic ignored "-Wswitch-enum"
void yyerror(YYLTYPE * loc, yyscan_t scanner, ParserState * state, const char * error) void yyerror(YYLTYPE * loc, yyscan_t scanner, ParserState * state, const char * error)
{ {
@ -96,7 +98,18 @@ void yyerror(YYLTYPE * loc, yyscan_t scanner, ParserState * state, const char *
std::vector<std::pair<nix::PosIdx, std::variant<nix::Expr *, nix::StringToken>>> * ind_string_parts; std::vector<std::pair<nix::PosIdx, std::variant<nix::Expr *, nix::StringToken>>> * ind_string_parts;
} }
%type <e> start expr expr_function expr_if expr_op %destructor { delete $$; } <e>
%destructor { delete $$; } <list>
%destructor { delete $$; } <attrs>
%destructor { delete $$; } <formals>
%destructor { delete $$; } <formal>
%destructor { delete $$; } <attrNames>
%destructor { delete $$; } <inheritAttrs>
%destructor { delete $$; } <string_parts>
%destructor { delete $$; } <ind_string_parts>
%type <e> start
%type <e> expr expr_function expr_if expr_op
%type <e> expr_select expr_simple expr_app %type <e> expr_select expr_simple expr_app
%type <list> expr_list %type <list> expr_list
%type <attrs> binds %type <attrs> binds
@ -134,7 +147,7 @@ void yyerror(YYLTYPE * loc, yyscan_t scanner, ParserState * state, const char *
%% %%
start: expr { state->result = $1; }; start: expr { state->result = $1; $$ = 0; };
expr: expr_function; expr: expr_function;