2019-09-24 Marek Polacek <polacek@redhat.com>
+ PR c++/91868 - improve -Wshadow location.
+ * name-lookup.c (check_local_shadow): Use DECL_SOURCE_LOCATION
+ instead of input_location.
+
PR c++/91845 - ICE with invalid pointer-to-member.
* expr.c (mark_use): Use error_operand_p.
* typeck2.c (build_m_component_ref): Check error_operand_p after
msg = "declaration of %qD shadows a previous local";
auto_diagnostic_group d;
- if (warning_at (input_location, warning_code, msg, decl))
+ if (warning_at (DECL_SOURCE_LOCATION (decl), warning_code, msg, decl))
inform_shadowed (old);
return;
}
|| TYPE_PTRMEMFUNC_P (TREE_TYPE (decl)))
{
auto_diagnostic_group d;
- if (warning_at (input_location, OPT_Wshadow,
+ if (warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wshadow,
"declaration of %qD shadows a member of %qT",
decl, current_nonlambda_class_type ())
&& DECL_P (member))
/* XXX shadow warnings in outer-more namespaces */
{
auto_diagnostic_group d;
- if (warning_at (input_location, OPT_Wshadow,
+ if (warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wshadow,
"declaration of %qD shadows a global declaration",
decl))
inform_shadowed (old);
2019-09-24 Marek Polacek <polacek@redhat.com>
+ PR c++/91868 - improve -Wshadow location.
+ * g++.dg/warn/Wshadow-16.C: New test.
+
PR c++/91845 - ICE with invalid pointer-to-member.
* g++.dg/cpp1y/pr91845.C: New test.
--- /dev/null
+// PR c++/91868 - improve -Wshadow location.
+// { dg-options "-Wshadow" }
+
+int global; // { dg-message "shadowed declaration" }
+
+struct S
+{
+ static int bar; // { dg-message "shadowed declaration" }
+ S (int i) { int bar // { dg-warning "19:declaration of .bar. shadows a member" }
+ (1);
+ int global // { dg-warning "9:declaration of .global. shadows a global declaration" }
+ (42);
+ }
+};
+
+void
+foo ()
+{
+ int xx; // { dg-message "shadowed declaration" }
+ {
+ S xx // { dg-warning "7:declaration of .xx. shadows a previous local" }
+ (42);
+ }
+}