diff options
author | Philip Herron <herron.philip@googlemail.com> | 2025-03-28 17:52:51 +0000 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-31 21:07:24 +0200 |
commit | 5d6467f637273418535316b051491e0ad594a194 (patch) | |
tree | e37f52c272f9e650878c77db676b1feda01183af /gcc | |
parent | 3729b279fbef2404d91f08009102e5dd497f5cb6 (diff) | |
download | gcc-5d6467f637273418535316b051491e0ad594a194.zip gcc-5d6467f637273418535316b051491e0ad594a194.tar.gz gcc-5d6467f637273418535316b051491e0ad594a194.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 8f2471d..7fc6467 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 {} |