diff options
author | Philip Herron <herron.philip@googlemail.com> | 2025-03-28 17:52:51 +0000 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2025-03-28 18:34:45 +0000 |
commit | 6130523c8b98178e6bdbde9e33a4ca8c95226bf1 (patch) | |
tree | f5456c38605eca6e9258ec692dd7c736cc2b85b8 /gcc | |
parent | 8d1c01c818428a432dc7a64237bdf62aa3fd0c6c (diff) | |
download | gcc-6130523c8b98178e6bdbde9e33a4ca8c95226bf1.zip gcc-6130523c8b98178e6bdbde9e33a4ca8c95226bf1.tar.gz gcc-6130523c8b98178e6bdbde9e33a4ca8c95226bf1.tar.bz2 |
gccrs: FIX ICE for malformed repr attribute
Fixes Rust-GCC#3614
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::parse_repr_options): check for input
gcc/testsuite/ChangeLog:
* rust/compile/issue-3614.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-base.cc | 6 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/issue-3614.rs | 3 |
2 files changed, 9 insertions, 0 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-base.cc b/gcc/rust/typecheck/rust-hir-type-check-base.cc index b6d2f03..f60b540 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-base.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-base.cc @@ -305,6 +305,12 @@ TypeCheckBase::parse_repr_options (const AST::AttrVec &attrs, location_t locus) for (const auto &attr : attrs) { bool is_repr = attr.get_path ().as_string () == Values::Attributes::REPR; + if (is_repr && !attr.has_attr_input ()) + { + rust_error_at (attr.get_locus (), "malformed %qs attribute", "repr"); + continue; + } + if (is_repr) { const AST::AttrInput &input = attr.get_attr_input (); diff --git a/gcc/testsuite/rust/compile/issue-3614.rs b/gcc/testsuite/rust/compile/issue-3614.rs new file mode 100644 index 0000000..350a7e4 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-3614.rs @@ -0,0 +1,3 @@ +#[repr] // { dg-error "malformed .repr. attribute" } + +struct _B {} |