@@ -3249,6 +3249,10 @@ check_local_shadow (tree decl)
enum opt_code warning_code;
if (warn_shadow)
warning_code = OPT_Wshadow;
+ else if ((TREE_CODE (decl) == TYPE_DECL)
+ ^ (TREE_CODE (old) == TYPE_DECL))
+ /* If exactly one is a type, they aren't compatible. */
+ warning_code = OPT_Wshadow_local;
else if ((TREE_TYPE (old)
&& TREE_TYPE (decl)
&& same_type_p (TREE_TYPE (old), TREE_TYPE (decl)))
new file mode 100644
@@ -0,0 +1,10 @@
+// PR c++/100608
+// { dg-do compile { target c++11 } }
+// { dg-additional-options "-Wshadow=compatible-local" }
+
+template <typename> class X {};
+
+void foo()
+{
+ auto a = X<class a>{}; // no warning, not compatible
+}