]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Avoid parsing const unsafe/extern functions as async
authorOwen Avery <powerboat9.gamer@gmail.com>
Tue, 26 Mar 2024 19:58:48 +0000 (15:58 -0400)
committerP-E-P <32375388+P-E-P@users.noreply.github.com>
Wed, 27 Mar 2024 12:38:45 +0000 (12:38 +0000)
gcc/rust/ChangeLog:

* parse/rust-parse-impl.h
(Parser::parse_vis_item):
Call parse_function instead of parse_async_item when finding
UNSAFE or EXTERN_KW during lookahead.

gcc/testsuite/ChangeLog:

* rust/compile/func-const-unsafe.rs: New test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
gcc/rust/parse/rust-parse-impl.h
gcc/testsuite/rust/compile/func-const-unsafe.rs [new file with mode: 0644]

index b6c2ca3fc0c9450425ac1ae2d7216cfcfe5cd0f4..263ca634ea5c9aa46414b7ded95ec6de338a8e2b 100644 (file)
@@ -1382,10 +1382,10 @@ Parser<ManagedTokenSource>::parse_vis_item (AST::AttrVec outer_attrs)
        case IDENTIFIER:
        case UNDERSCORE:
          return parse_const_item (std::move (vis), std::move (outer_attrs));
-       case UNSAFE:
-       case EXTERN_KW:
        case ASYNC:
          return parse_async_item (std::move (vis), std::move (outer_attrs));
+       case UNSAFE:
+       case EXTERN_KW:
        case FN_KW:
          return parse_function (std::move (vis), std::move (outer_attrs));
        default:
diff --git a/gcc/testsuite/rust/compile/func-const-unsafe.rs b/gcc/testsuite/rust/compile/func-const-unsafe.rs
new file mode 100644 (file)
index 0000000..9c932bd
--- /dev/null
@@ -0,0 +1 @@
+pub const unsafe fn foo() {}