===================================================================
@@ -1277,7 +1277,10 @@ pushdecl_maybe_friend_1 (tree x, bool is_friend)
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)))
+ && (current_instantiation () == NULL
+ || (current_instantiation ()->decl
+ != current_function_decl)))
/* XXX shadow warnings in outer-more namespaces */
{
if (warning_at (input_location, OPT_Wshadow,
===================================================================
@@ -0,0 +1,15 @@
+// PR c++/56100
+// { dg-options "-Wshadow" }
+
+struct bar
+{
+ template <typename T>
+ void baz () { int foo; }
+};
+
+int foo;
+
+int main ()
+{
+ bar ().baz <int> ();
+}
===================================================================
@@ -0,0 +1,15 @@
+// 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> ();
+}
===================================================================
@@ -0,0 +1,15 @@
+// PR c++/56100
+// { dg-options "-Wshadow" }
+
+template <typename T>
+struct bar
+{
+ void baz () { int foo; }
+};
+
+int foo;
+
+int main ()
+{
+ bar <int> ().baz ();
+}
===================================================================
@@ -0,0 +1,15 @@
+// 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 ();
+}