diff options
author | Philip Herron <herron.philip@googlemail.com> | 2025-04-17 15:53:58 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2025-04-18 16:06:33 +0000 |
commit | 4d70c16011e809a6732a0c34f1fc23ca75851476 (patch) | |
tree | 36ca5a6191a9041da1acc9dcf7a3418337f465ae /gcc/rust | |
parent | 47d55fe8cb022d11b7899f8e93761a61ee38c583 (diff) | |
download | gcc-4d70c16011e809a6732a0c34f1fc23ca75851476.zip gcc-4d70c16011e809a6732a0c34f1fc23ca75851476.tar.gz gcc-4d70c16011e809a6732a0c34f1fc23ca75851476.tar.bz2 |
gccrs: Fix ICE with empty generic arguments
We have an assertion when accessing generic args if there are any which
is really useful so this adds the missing guards for the case where
they are specified but empty.
Fixes Rust-GCC#3649
gcc/rust/ChangeLog:
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): add guard
* expand/rust-expand-visitor.cc (ExpandVisitor::visit): add guard
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: nr2 is missing error for this
* rust/compile/issue-3649.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/rust')
-rw-r--r-- | gcc/rust/ast/rust-ast-visitor.cc | 3 | ||||
-rw-r--r-- | gcc/rust/expand/rust-expand-visitor.cc | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/gcc/rust/ast/rust-ast-visitor.cc b/gcc/rust/ast/rust-ast-visitor.cc index 5774102..4d4e89c 100644 --- a/gcc/rust/ast/rust-ast-visitor.cc +++ b/gcc/rust/ast/rust-ast-visitor.cc @@ -108,7 +108,8 @@ DefaultASTVisitor::visit (GenericArgsBinding &binding) void DefaultASTVisitor::visit (AST::TypePathSegmentGeneric &segment) { - visit (segment.get_generic_args ()); + if (segment.has_generic_args ()) + visit (segment.get_generic_args ()); } void diff --git a/gcc/rust/expand/rust-expand-visitor.cc b/gcc/rust/expand/rust-expand-visitor.cc index b5e65b5..c6c1ba4 100644 --- a/gcc/rust/expand/rust-expand-visitor.cc +++ b/gcc/rust/expand/rust-expand-visitor.cc @@ -489,7 +489,8 @@ ExpandVisitor::visit (AST::PathInExpression &path) void ExpandVisitor::visit (AST::TypePathSegmentGeneric &segment) { - expand_generic_args (segment.get_generic_args ()); + if (segment.has_generic_args ()) + expand_generic_args (segment.get_generic_args ()); } void |