From a5d37a807129e995d2f91e098658c497bfe514fb Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Wed, 20 Sep 2023 09:53:00 -0400 Subject: [PATCH] allow `unsafe` and `ref` in grammar `unsafe` and ref returns are allowed for delegates, local functions, and methods. Update the grammar for that part. Fixes #886 See https://github.com/dotnet/csharpstandard/pull/941#pullrequestreview-1634196517 --- standard/classes.md | 2 +- standard/delegates.md | 8 ++------ standard/statements.md | 10 +++++++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/standard/classes.md b/standard/classes.md index e7b7c61d0..b711eff63 100644 --- a/standard/classes.md +++ b/standard/classes.md @@ -1930,7 +1930,6 @@ method_header method_modifier : ref_method_modifier | 'async' - | unsafe_modifier // unsafe code support ; ref_method_modifier @@ -1945,6 +1944,7 @@ ref_method_modifier | 'override' | 'abstract' | 'extern' + | unsafe_modifier // unsafe code support ; return_type diff --git a/standard/delegates.md b/standard/delegates.md index 54b568f2c..0932f7388 100644 --- a/standard/delegates.md +++ b/standard/delegates.md @@ -13,7 +13,7 @@ A *delegate_declaration* is a *type_declaration* ([ยง14.7](namespaces.md#147-typ ```ANTLR delegate_declaration : attributes? delegate_modifier* 'delegate' return_type delegate_header - | attributes? ref_delegate_modifier* 'delegate' ref_kind ref_return_type delegate_header + | attributes? delegate_modifier* 'delegate' ref_kind ref_return_type delegate_header ; delegate_header @@ -22,16 +22,12 @@ delegate_header ; delegate_modifier - : ref_delegate_modifier - | unsafe_modifier // unsafe code support - ; - -ref_delegate_modifier : 'new' | 'public' | 'protected' | 'internal' | 'private' + | unsafe_modifier // unsafe code support ; ``` diff --git a/standard/statements.md b/standard/statements.md index 6a0c07a97..00abf5dd5 100644 --- a/standard/statements.md +++ b/standard/statements.md @@ -447,7 +447,7 @@ A *local_function_declaration* declares a local function. ```ANTLR local_function_declaration : local_function_modifier* return_type local_function_header local_function_body - | ref_kind ref_return_type local_function_header ref_local_function_body + | ref_local_function_modifier* ref_kind ref_return_type local_function_header ref_local_function_body ; local_function_header @@ -456,8 +456,12 @@ local_function_header ; local_function_modifier - : 'async' - | unsafe_modifier // unsafe code support + : ref_local_function_modifier + | 'async' + ; + +ref_local_function_modifier + : unsafe_modifier // unsafe code support ; local_function_body