From c16d0bae7bedaf9819436426aaf0abe87380cf63 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 11 Feb 2023 20:31:08 +0900 Subject: [PATCH] [qfcc] Fix handling of storage class {...} blocks Another victim of the type system, but this one was due to the handling of storage classes in general. --- tools/qfcc/source/qc-parse.y | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/tools/qfcc/source/qc-parse.y b/tools/qfcc/source/qc-parse.y index 3cebea392..427d0eb4a 100644 --- a/tools/qfcc/source/qc-parse.y +++ b/tools/qfcc/source/qc-parse.y @@ -260,6 +260,12 @@ parse_attributes (attribute_t *attr_list) return spec; } +static int +storage_auto (specifier_t spec) +{ + return spec.storage == sc_global || spec.storage == sc_local; +} + static specifier_t spec_merge (specifier_t spec, specifier_t new) { @@ -275,8 +281,8 @@ spec_merge (specifier_t spec, specifier_t new) spec.multi_type = 1; } } - if (new.is_typedef || new.storage) { - if ((spec.is_typedef || spec.storage) && !spec.multi_store) { + if (new.is_typedef || !storage_auto (new)) { + if ((spec.is_typedef || !storage_auto (spec)) && !spec.multi_store) { error (0, "multiple storage classes in declaration specifiers"); spec.multi_store = 1; } @@ -774,16 +780,16 @@ typespec : typespec_reserved { $$ = $1; - //if (!$$.storage) { - // $$.storage = current_storage; - //} + if (!$$.storage) { + $$.storage = current_storage; + } } | typespec_nonreserved { $$ = $1; - //if (!$$.storage) { - // $$.storage = current_storage; - //} + if (!$$.storage) { + $$.storage = current_storage; + } } ; @@ -1566,7 +1572,7 @@ vector_expr cast_expr : '(' typename ')' cast_expr { - $$ = cast_expr ($2.type, $4); + $$ = cast_expr (find_type ($2.type), $4); } | unary_expr %prec LOW ;