gcc/rust/ChangeLog:
* checks/lints/unused/rust-unused-checker.cc (UnusedChecker::visit):
Add warning for static variables.
gcc/testsuite/ChangeLog:
* rust/compile/non-upper-case-globals_0.rs: New test.
Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.com>
rust_warning_at (item.get_locus (), OPT_Wunused_variable,
"unused variable %qs",
item.get_identifier ().as_string ().c_str ());
+
+ if (!std::all_of (var_name.begin (), var_name.end (), [] (unsigned char c) {
+ return ISUPPER (c) || ISDIGIT (c) || c == '_';
+ }))
+ rust_warning_at (item.get_locus (), OPT_Wunused_variable,
+ "static variable %qs should have an upper case name",
+ var_name.c_str ());
}
void
--- /dev/null
+// { dg-additional-options "-frust-unused-check-2.0" }
+
+static _my_static : i32 = 0;
+// { dg-warning "static variable ._my_static. should have an upper case name" "" { target *-*-* } .-1 }