From: Mason Pike Date: Fri, 26 Dec 2025 15:06:51 +0000 (+0100) Subject: gccrs: add outer attributes X-Git-Tag: basepoints/gcc-17~1014 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=44fc64a08bacbb686be102ea36c063487158f849;p=thirdparty%2Fgcc.git gccrs: add outer attributes gcc/rust/ChangeLog: * util/rust-attributes.cc: add attributes to the __outer_attributes set. This prevents some inconsistent behavior, like: https://godbolt.org/z/Eq1GE7xxY Signed-off-by: Mason Pike --- diff --git a/gcc/rust/util/rust-attributes.cc b/gcc/rust/util/rust-attributes.cc index 8c7e0639b85..1f465f2bda1 100644 --- a/gcc/rust/util/rust-attributes.cc +++ b/gcc/rust/util/rust-attributes.cc @@ -124,9 +124,23 @@ static const BuiltinAttrDefinition __definitions[] {Attrs::TEST, CODE_GENERATION}}; static const std::set __outer_attributes - = {Attrs::INLINE, Attrs::DERIVE_ATTR, Attrs::ALLOW_INTERNAL_UNSTABLE, - Attrs::LANG, Attrs::REPR, Attrs::PATH, - Attrs::TARGET_FEATURE, Attrs::TEST}; + = {Attrs::INLINE, + Attrs::DERIVE_ATTR, + Attrs::ALLOW_INTERNAL_UNSTABLE, + Attrs::LANG, + Attrs::REPR, + Attrs::PATH, + Attrs::TARGET_FEATURE, + Attrs::TEST, + Attrs::COLD, + Attrs::MACRO_USE, + Attrs::MACRO_EXPORT, + Attrs::PROC_MACRO_ATTRIBUTE, + Attrs::PROC_MACRO_DERIVE, + Attrs::DEPRECATED, + Attrs::MUST_USE, + Attrs::LINK_NAME, + Attrs::LINK_SECTION}; BuiltinAttributeMappings * BuiltinAttributeMappings::get () diff --git a/gcc/testsuite/rust/compile/no-crate-level-outer-attr.rs b/gcc/testsuite/rust/compile/no-crate-level-outer-attr.rs new file mode 100644 index 00000000000..a238c28f1ee --- /dev/null +++ b/gcc/testsuite/rust/compile/no-crate-level-outer-attr.rs @@ -0,0 +1,2 @@ +#![cold] // { dg-error "attribute cannot be used at crate level" } +pub fn test() {}