From: Mason Pike <[email protected]> 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 <[email protected]> --- This change was merged into the gccrs repository and is posted here for upstream visibility and potential drive-by review, as requested by GCC release managers. Each commit email contains a link to its details on github from where you can find the Pull-Request and associated discussions. Commit on github: https://github.com/Rust-GCC/gccrs/commit/6f7b08727da5854d3d9d2977ee8dbbc4790332f7 The commit has been mentioned in the following pull-request(s): - https://github.com/Rust-GCC/gccrs/pull/4339 gcc/rust/util/rust-attributes.cc | 20 ++++++++++++++++--- .../rust/compile/no-crate-level-outer-attr.rs | 2 ++ 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/rust/compile/no-crate-level-outer-attr.rs diff --git a/gcc/rust/util/rust-attributes.cc b/gcc/rust/util/rust-attributes.cc index 8c7e0639b..1f465f2bd 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<std::string> __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 000000000..a238c28f1 --- /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() {} -- 2.52.0
