}
+ warn_shadow_symbol (name, scope_start_count, line, start, caret, 0);
new_size = align_up_long (current_local_stack_size + size, align);
/*
}
+ warn_shadow_symbol (name, scope_start_count, line, start, caret, 0);
+
local_symbols[local_symbol_count].name = xstrdup (name);
local_symbols[local_symbol_count].static_label = xstrdup (label);
local_symbols[local_symbol_count].size = size;
report_line_at (get_filename (), get_line_number (), REPORT_ERROR, tok.report_start, tok.report_caret, "duplicate parameter '%s'", pending_params[i].name);
}
+ warn_shadow_symbol (pending_params[i].name, 0, pending_params[i].decl_line,
+ pending_params[i].decl_start, pending_params[i].decl_start ? pending_params[i].decl_start + pending_params[i].decl_caret_offset : 0, 1);
+
local_symbols[local_symbol_count].name = xstrdup (pending_params[i].name);
local_symbols[local_symbol_count].size = pending_params[i].size;
local_symbols[local_symbol_count].align = pending_params[i].align;
#define WARN_DEFAULT (WARN_DUP_DEFINE | WARN_UNREACHABLE)
#define WARN_ALL (WARN_DEFAULT | WARN_NO_RETURN | WARN_SIGNEDNESS | WARN_UNUSED | WARN_FALLTHROUGH | WARN_INITIALIZER)
-#define WARN_EXTRA (WARN_ALL | WARN_CONVERSION | WARN_SHADOW | WARN_OLD_STYLE)
+#define WARN_EXTRA (WARN_ALL | WARN_CONVERSION | WARN_OLD_STYLE)
struct cc_state {
}
+ warn_shadow_symbol (name, scope_start_count, line, start, caret, 0);
new_size = align_up_long (current_local_stack_size + size, align);
/*
}
+ warn_shadow_symbol (name, scope_start_count, line, start, caret, 0);
+
local_symbols[local_symbol_count].name = xstrdup (name);
local_symbols[local_symbol_count].static_label = xstrdup (label);
local_symbols[local_symbol_count].size = size;
report_line_at (get_filename (), get_line_number (), REPORT_ERROR, tok.report_start, tok.report_caret, "duplicate parameter '%s'", pending_params[i].name);
}
+ warn_shadow_symbol (pending_params[i].name, 0, pending_params[i].decl_line,
+ pending_params[i].decl_start, pending_params[i].decl_start ? pending_params[i].decl_start + pending_params[i].decl_caret_offset : 0, 1);
+
local_symbols[local_symbol_count].name = xstrdup (pending_params[i].name);
local_symbols[local_symbol_count].size = pending_params[i].size;
local_symbols[local_symbol_count].align = pending_params[i].align;
}
+ if (strcmp (optarg, "shadow") == 0) {
+
+ state->warn |= WARN_SHADOW;
+ break;
+
+ }
+
report_at (program_name, 0, REPORT_ERROR, "unrecognised -W argument");
exit (EXIT_FAILURE);
}
+void warn_shadow_symbol (const char *name, int scope_start_count, int line, const char *start, const char *caret, int is_parameter) {
+
+ const char *what = 0;
+ int i;
+
+ if (!state || !(state->warn & WARN_SHADOW) || !name) {
+ return;
+ }
+
+ if (!is_parameter) {
+
+ if (scope_start_count < 0) {
+ scope_start_count = 0;
+ }
+
+ if (scope_start_count > local_symbol_count) {
+ scope_start_count = local_symbol_count;
+ }
+
+ for (i = scope_start_count - 1; i >= 0; i--) {
+
+ if (local_symbols[i].name && strcmp (local_symbols[i].name, name) == 0) {
+
+ what = local_symbols[i].offset > 0 ? "parameter" : "local variable";
+ break;
+
+ }
+
+ }
+
+ }
+
+ if (!what && find_global_symbol (name) >= 0) {
+ what = "global declaration";
+ }
+
+ if (!what) {
+ return;
+ }
+
+ if (start && caret) {
+
+ report_line_at (get_filename (), line, REPORT_WARNING, start, caret,
+ "declaration of '%s' shadows a %s", name, what);
+
+ } else {
+ report_at (get_filename (), line, REPORT_WARNING, "declaration of '%s' shadows a %s", name, what);
+ }
+
+}
+
void warn_unused_local_symbols (int start, const char *filename) {
int i;
struct local_symbol *find_local_symbol (const char *name);
struct local_symbol *peek_local_symbol (const char *name);
+void warn_shadow_symbol (const char *name, int scope_start_count, int line, const char *start, const char *caret, int is_parameter);
void warn_unused_local_symbols (int start, const char *filename);
void warn_unused_static_functions (const char *filename);