static constexpr auto &PROC_MACRO_DERIVE = "proc_macro_derive";
static constexpr auto &PROC_MACRO_ATTRIBUTE = "proc_macro_attribute";
+ static constexpr auto &DERIVE = "derive";
+
static constexpr auto &TARGET_FEATURE = "target_feature";
// From now on, these are reserved by the compiler and gated through
// #![feature(rustc_attrs)]
{Attrs::PROC_MACRO, EXPANSION},
{Attrs::PROC_MACRO_DERIVE, EXPANSION},
{Attrs::PROC_MACRO_ATTRIBUTE, EXPANSION},
+
+ {Attrs::DERIVE, EXPANSION},
// FIXME: This is not implemented yet, see
// https://github.com/Rust-GCC/gccrs/issues/1475
{Attrs::TARGET_FEATURE, CODE_GENERATION},
void
AttributeChecker::visit (AST::Crate &crate)
{
+ check_inner_attributes (crate.get_inner_attrs ());
check_attributes (crate.get_inner_attrs ());
for (auto &item : crate.items)
check_doc_attribute (attribute);
}
+void
+AttributeChecker::check_inner_attributes (const AST::AttrVec &attributes)
+{
+ for (auto &attr : attributes)
+ if (attr.is_derive ())
+ rust_error_at (attr.get_locus (),
+ "derive attribute cannot be used at crate level");
+}
+
void
AttributeChecker::check_attributes (const AST::AttrVec &attributes)
{
void check_attribute (const AST::Attribute &attribute);
/* Check the validity of all given attributes */
+
+ void check_inner_attributes (const AST::AttrVec &attributes);
void check_attributes (const AST::AttrVec &attributes);
// rust-ast.h
--- /dev/null
+#![derive(PartialOrd, PartialEq)]
+// { dg-error "derive attribute cannot be used at crate level" "" { target *-*-* } .-1 }
+pub fn check_ge(a: i32, b: i32) -> bool {
+ a >= b
+}