Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions gcc/rust/expand/rust-macro-expand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -962,12 +962,10 @@ transcribe_expression (Parser<MacroInvocLexer> &parser)

auto attrs = parser.parse_outer_attributes ();
auto expr = parser.parse_expr (std::move (attrs));
if (expr == nullptr)
{
for (auto error : parser.get_errors ())
error.emit ();
return AST::Fragment::create_error ();
}
for (auto error : parser.get_errors ())
error.emit ();
if (!expr)
return AST::Fragment::create_error ();

// FIXME: make this an error for some edititons
if (parser.peek_current_token ()->get_id () == SEMICOLON)
Expand Down Expand Up @@ -997,6 +995,8 @@ transcribe_type (Parser<MacroInvocLexer> &parser)
auto type = parser.parse_type (true);
for (auto err : parser.get_errors ())
err.emit ();
if (!type)
return AST::Fragment::create_error ();

auto end = lexer.get_offs ();

Expand All @@ -1018,6 +1018,9 @@ transcribe_pattern (Parser<MacroInvocLexer> &parser)
for (auto err : parser.get_errors ())
err.emit ();

if (!pattern)
return AST::Fragment::create_error ();

auto end = lexer.get_offs ();

return AST::Fragment ({std::move (pattern)},
Expand Down
18 changes: 18 additions & 0 deletions gcc/testsuite/rust/compile/issue-4140-1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
pub enum TypeCtor {
Slice,
Array,
}
pub struct B<T>(T);

macro_rules! ty_app {
($_a:pat) => {
ApplicationTy($ctor) // { dg-error "unexpected token '$' in typle struct items" "4140" { target *-*-* } . }

Check failure on line 9 in gcc/testsuite/rust/compile/issue-4140-1.rs

View workflow job for this annotation

GitHub Actions / build-and-check-ubuntu-32bit

Test failure (FAIL)

4140 at line 10 (test for errors, line 9)

Check failure on line 9 in gcc/testsuite/rust/compile/issue-4140-1.rs

View workflow job for this annotation

GitHub Actions / build-and-check-ubuntu-32bit

Test failure (FAIL)

4140 (test for errors, line 9)

Check failure on line 9 in gcc/testsuite/rust/compile/issue-4140-1.rs

View workflow job for this annotation

GitHub Actions / build-and-check-ubuntu-64bit

Test failure (FAIL)

4140 at line 10 (test for errors, line 9)

Check failure on line 9 in gcc/testsuite/rust/compile/issue-4140-1.rs

View workflow job for this annotation

GitHub Actions / build-and-check-ubuntu-64bit

Test failure (FAIL)

4140 (test for errors, line 9)

Check failure on line 9 in gcc/testsuite/rust/compile/issue-4140-1.rs

View workflow job for this annotation

GitHub Actions / build-and-check-ubuntu-64bit-glibcxx

Test failure (FAIL)

4140 at line 10 (test for errors, line 9)

Check failure on line 9 in gcc/testsuite/rust/compile/issue-4140-1.rs

View workflow job for this annotation

GitHub Actions / build-and-check-ubuntu-64bit-glibcxx

Test failure (FAIL)

4140 (test for errors, line 9)

Check failure on line 9 in gcc/testsuite/rust/compile/issue-4140-1.rs

View workflow job for this annotation

GitHub Actions / build-alpine-32bit-and-check-alpine-32bit

Test failure (FAIL)

4140 at line 10 (test for errors, line 9)

Check failure on line 9 in gcc/testsuite/rust/compile/issue-4140-1.rs

View workflow job for this annotation

GitHub Actions / build-alpine-32bit-and-check-alpine-32bit

Test failure (FAIL)

4140 (test for errors, line 9)

Check failure on line 9 in gcc/testsuite/rust/compile/issue-4140-1.rs

View workflow job for this annotation

GitHub Actions / build-and-check-asan

Test failure (FAIL)

4140 at line 10 (test for errors, line 9)

Check failure on line 9 in gcc/testsuite/rust/compile/issue-4140-1.rs

View workflow job for this annotation

GitHub Actions / build-and-check-asan

Test failure (FAIL)

4140 (test for errors, line 9)
// { dg-error "failed to parse typle struct items" "4140" { target *-*-*} .-1 }
};
}

Check failure on line 13 in gcc/testsuite/rust/compile/issue-4140-1.rs

View workflow job for this annotation

GitHub Actions / build-and-check-ubuntu-32bit

Test failure (FAIL)

4140 at line 14 (test for errors, line 13)

Check failure on line 13 in gcc/testsuite/rust/compile/issue-4140-1.rs

View workflow job for this annotation

GitHub Actions / build-and-check-ubuntu-64bit

Test failure (FAIL)

4140 at line 14 (test for errors, line 13)

Check failure on line 13 in gcc/testsuite/rust/compile/issue-4140-1.rs

View workflow job for this annotation

GitHub Actions / build-and-check-ubuntu-64bit-glibcxx

Test failure (FAIL)

4140 at line 14 (test for errors, line 13)

Check failure on line 13 in gcc/testsuite/rust/compile/issue-4140-1.rs

View workflow job for this annotation

GitHub Actions / build-alpine-32bit-and-check-alpine-32bit

Test failure (FAIL)

4140 at line 14 (test for errors, line 13)

Check failure on line 13 in gcc/testsuite/rust/compile/issue-4140-1.rs

View workflow job for this annotation

GitHub Actions / build-and-check-asan

Test failure (FAIL)

4140 at line 14 (test for errors, line 13)
pub fn foo(ty: ApplicationTy) { // { dg-error "could not resolve type path 'ApplicationTy'" "4140" { target *-*-* } .-1 }
match ty {
ty_app!(bean::Array) => {}
}
}
11 changes: 11 additions & 0 deletions gcc/testsuite/rust/compile/issue-4140-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
macro_rules! ty_app {
($_a:pat) => {
($ctor) // { dg-error "unrecognised token '$' in grouped or tuple pattern after first pattern" "4140" { target *-*-* } . }

Check failure on line 3 in gcc/testsuite/rust/compile/issue-4140-2.rs

View workflow job for this annotation

GitHub Actions / build-and-check-ubuntu-32bit

Test failure (FAIL)

4140 (test for errors, line 3)

Check failure on line 3 in gcc/testsuite/rust/compile/issue-4140-2.rs

View workflow job for this annotation

GitHub Actions / build-and-check-ubuntu-64bit

Test failure (FAIL)

4140 (test for errors, line 3)

Check failure on line 3 in gcc/testsuite/rust/compile/issue-4140-2.rs

View workflow job for this annotation

GitHub Actions / build-and-check-ubuntu-64bit-glibcxx

Test failure (FAIL)

4140 (test for errors, line 3)

Check failure on line 3 in gcc/testsuite/rust/compile/issue-4140-2.rs

View workflow job for this annotation

GitHub Actions / build-alpine-32bit-and-check-alpine-32bit

Test failure (FAIL)

4140 (test for errors, line 3)

Check failure on line 3 in gcc/testsuite/rust/compile/issue-4140-2.rs

View workflow job for this annotation

GitHub Actions / build-and-check-asan

Test failure (FAIL)

4140 (test for errors, line 3)
};
}

pub fn foo() {

Check failure on line 7 in gcc/testsuite/rust/compile/issue-4140-2.rs

View workflow job for this annotation

GitHub Actions / build-and-check-ubuntu-32bit

Test failure (FAIL)

4140 at line 8 (test for errors, line 7)

Check failure on line 7 in gcc/testsuite/rust/compile/issue-4140-2.rs

View workflow job for this annotation

GitHub Actions / build-and-check-ubuntu-64bit

Test failure (FAIL)

4140 at line 8 (test for errors, line 7)

Check failure on line 7 in gcc/testsuite/rust/compile/issue-4140-2.rs

View workflow job for this annotation

GitHub Actions / build-and-check-ubuntu-64bit-glibcxx

Test failure (FAIL)

4140 at line 8 (test for errors, line 7)

Check failure on line 7 in gcc/testsuite/rust/compile/issue-4140-2.rs

View workflow job for this annotation

GitHub Actions / build-alpine-32bit-and-check-alpine-32bit

Test failure (FAIL)

4140 at line 8 (test for errors, line 7)

Check failure on line 7 in gcc/testsuite/rust/compile/issue-4140-2.rs

View workflow job for this annotation

GitHub Actions / build-and-check-asan

Test failure (FAIL)

4140 at line 8 (test for errors, line 7)
match ty { // { dg-error "Cannot find path 'ty' in this scope" "4140" { target *-*-* } .-1 }
ty_app!(bean::Array) => {}
}
}
Loading