From 20d82bbdcb45b20417c05cf85112dcedf1f901b8 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 22 Mar 2022 12:00:43 +0100 Subject: [PATCH] Simplify class end label parser rule The current class end label parser rule gets the data type from the TYPE_IDENTIFIER, casts that to a class_type_t and gets the name from that. This code was written when the TYPE_IDENTIFIER only provided the data type. But these days it provides both the data type and the name. Simplify the code to get the name directly from the TYPE_IDENTIIFER. Signed-off-by: Lars-Peter Clausen --- parse.y | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/parse.y b/parse.y index 816c81336..be48f8f94 100644 --- a/parse.y +++ b/parse.y @@ -824,20 +824,9 @@ class_identifier the class name is detected by the lexor as a TYPE_IDENTIFIER if it does indeed match a name. */ class_declaration_endlabel_opt - : ':' TYPE_IDENTIFIER - { class_type_t*tmp = dynamic_cast ($2.type); - if (tmp == 0) { - yyerror(@2, "error: class declaration endlabel \"%s\" is not a class name\n", $2.text); - $$ = 0; - } else { - $$ = strdupnew(tmp->name.str()); - } - delete[]$2.text; - } - | ':' IDENTIFIER - { $$ = $2; } - | - { $$ = 0; } + : ':' TYPE_IDENTIFIER { $$ = $2.text; } + | ':' IDENTIFIER { $$ = $2; } + | { $$ = 0; } ; /* This rule implements [ extends class_type ] in the