From ab10383aaebf2feebd2b6d68247f2520eff48f79 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 26 Oct 2021 10:50:40 -0700 Subject: compiler: permit compiler directives in parenthesized groups The original compiler directive support was only for //line at the start of a line and for //go: comments before function declarations. When support was added for //go:notinheap for types and //go:embed for variables the code did not adapt to permit spaces before the comment or to permit the comments in var() or type() groups. This change corrects those omissions. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/358699 --- gcc/go/gofrontend/parse.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'gcc/go/gofrontend/parse.h') diff --git a/gcc/go/gofrontend/parse.h b/gcc/go/gofrontend/parse.h index 2c3c505..6e300ef 100644 --- a/gcc/go/gofrontend/parse.h +++ b/gcc/go/gofrontend/parse.h @@ -181,15 +181,14 @@ class Parse void method_spec(Typed_identifier_list*); void declaration(); bool declaration_may_start_here(); - void decl(void (Parse::*)(unsigned int, std::vector*), - unsigned int pragmas, std::vector* embeds); - void list(void (Parse::*)(unsigned int, std::vector*), bool); + void decl(void (Parse::*)()); + void list(void (Parse::*)(), bool); void const_decl(); void const_spec(int, Type**, Expression_list**); - void type_decl(unsigned int pragmas); - void type_spec(unsigned int pragmas, std::vector*); - void var_decl(std::vector* embeds); - void var_spec(unsigned int pragmas, std::vector*); + void type_decl(); + void type_spec(); + void var_decl(); + void var_spec(); void init_vars(const Typed_identifier_list*, Type*, Expression_list*, bool is_coloneq, std::vector*, Location); bool init_vars_from_call(const Typed_identifier_list*, Type*, Expression*, @@ -210,7 +209,7 @@ class Parse void simple_var_decl_or_assignment(const std::string&, Location, bool may_be_composite_lit, Range_clause*, Type_switch*); - void function_decl(unsigned int pragmas); + void function_decl(); Typed_identifier* receiver(); Expression* operand(bool may_be_sink, bool *is_parenthesized); Expression* enclosing_var_reference(Named_object*, Named_object*, @@ -278,7 +277,10 @@ class Parse void goto_stat(); void package_clause(); void import_decl(); - void import_spec(unsigned int pragmas, std::vector*); + void import_spec(); + + // Check for unused compiler directives. + void check_directives(); // Skip past an error looking for a semicolon or OP. Return true if // all is well, false if we found EOF. -- cgit v1.1