extern bool problematic_instantiation_changed (void);
extern void record_last_problematic_instantiation (void);
extern struct tinst_level *current_instantiation(void);
+extern bool instantiating_current_function_p (void);
extern tree maybe_get_template_decl_from_type_decl (tree);
extern int processing_template_parmlist;
extern bool dependent_type_p (tree);
/* If this is a locally defined typedef in a function that
is not a template instantation, record it to implement
-Wunused-local-typedefs. */
- if (current_instantiation () == NULL
- || (current_instantiation ()->decl != current_function_decl))
- record_locally_defined_typedef (x);
+ if (!instantiating_current_function_p ())
+ record_locally_defined_typedef (x);
}
/* Multiple external decls of the same identifier ought to match.
old and new decls are type decls. */
|| (TREE_CODE (oldglobal) == TYPE_DECL
&& (!DECL_ARTIFICIAL (oldglobal)
- || TREE_CODE (x) == TYPE_DECL))))
+ || TREE_CODE (x) == TYPE_DECL)))
+ && !instantiating_current_function_p ())
/* XXX shadow warnings in outer-more namespaces */
{
if (warning_at (input_location, OPT_Wshadow,
return current_tinst_level;
}
+/* Return TRUE if current_function_decl is being instantiated, false
+ otherwise. */
+
+bool
+instantiating_current_function_p (void)
+{
+ return (current_instantiation ()
+ && current_instantiation ()->decl == current_function_decl);
+}
+
/* [temp.param] Check that template non-type parm TYPE is of an allowable
type. Return zero for ok, nonzero for disallowed. Issue error and
warning messages under control of COMPLAIN. */
+2015-04-01 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/56100
+ * g++.dg/warn/Wshadow-8.C: New.
+ * g++.dg/warn/Wshadow-9.C: Likewise.
+ * g++.dg/warn/Wshadow-10.C: Likewise.
+ * g++.dg/warn/Wshadow-11.C: Likewise.
+
2015-04-01 Bernd Edlinger <bernd.edlinger@hotmail.de>
* gcc.dg/pr23623.c: Added aligned attribute.
--- /dev/null
+// PR c++/56100
+// { dg-options "-Wshadow" }
+
+struct bar
+{
+ template <typename T>
+ void baz () { int foo; }
+};
+
+int foo;
+
+int main ()
+{
+ bar ().baz <int> ();
+}
--- /dev/null
+// PR c++/56100
+// { dg-options "-Wshadow" }
+
+int foo; // { dg-message "shadowed declaration" }
+
+struct bar
+{
+ template <typename T>
+ void baz () { int foo; } // { dg-warning "shadows a global" }
+};
+
+int main ()
+{
+ bar ().baz <int> ();
+}
--- /dev/null
+// PR c++/56100
+// { dg-options "-Wshadow" }
+
+template <typename T>
+struct bar
+{
+ void baz () { int foo; }
+};
+
+int foo;
+
+int main ()
+{
+ bar <int> ().baz ();
+}
--- /dev/null
+// PR c++/56100
+// { dg-options "-Wshadow" }
+
+int foo; // { dg-message "shadowed declaration" }
+
+template <typename T>
+struct bar
+{
+ void baz () { int foo; } // { dg-warning "shadows a global" }
+};
+
+int main ()
+{
+ bar <int> ().baz ();
+}