[PR c++/82424] Dont convert dependent types
authorNathan Sidwell <nathan@acm.org>
Fri, 6 Oct 2017 16:02:13 +0000 (16:02 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Fri, 6 Oct 2017 16:02:13 +0000 (16:02 +0000)
https://gcc.gnu.org/ml/gcc-patches/2017-10/msg00385.html
cp/
PR c++/82424
* name-lookup.c (check_local_shadow): Don't try and convert
dependent types.

testsuite/
PR c++/82424
* g++.dg/warn/pr82424.C: New.

From-SVN: r253496

gcc/cp/ChangeLog
gcc/cp/name-lookup.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/pr82424.C [new file with mode: 0644]

index ea0e8b6f9c808fe53d43865b431f0f7c912c8308..b2813ebf21187413f71a8c820f1f6992a74ab074 100644 (file)
@@ -1,3 +1,9 @@
+2017-10-06  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/82424
+       * name-lookup.c (check_local_shadow): Don't try and convert
+       dependent types.
+
 2017-10-06  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/82299
index fb86310c88458a92e5e6f35e4c115cb4bce5f523..a3da34d7549c8f44c6e936b33dc58be5440e6a94 100644 (file)
@@ -2728,7 +2728,11 @@ check_local_shadow (tree decl)
       else if (warn_shadow_local)
        warning_code = OPT_Wshadow_local;
       else if (warn_shadow_compatible_local
-              && can_convert (TREE_TYPE (old), TREE_TYPE (decl), tf_none))
+              && (same_type_p (TREE_TYPE (old), TREE_TYPE (decl))
+                  || (!dependent_type_p (TREE_TYPE (decl))
+                      && !dependent_type_p (TREE_TYPE (old))
+                      && can_convert (TREE_TYPE (old), TREE_TYPE (decl),
+                                      tf_none))))
        warning_code = OPT_Wshadow_compatible_local;
       else
        return;
index d7af2a93b5a42a129a8a27385d6357c840092614..97825c3319c4db18be2c718f0f3c6f332434f075 100644 (file)
@@ -1,3 +1,8 @@
+2017-10-06  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/82424
+       * g++.dg/warn/pr82424.C: New.
+
 2017-10-06  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/82299
diff --git a/gcc/testsuite/g++.dg/warn/pr82424.C b/gcc/testsuite/g++.dg/warn/pr82424.C
new file mode 100644 (file)
index 0000000..43dd5e4
--- /dev/null
@@ -0,0 +1,20 @@
+// { dg-additional-options "-Wshadow=compatible-local" }
+
+// pr c++/82424 we were trying to convert between dependent types.
+template <typename T> class a
+{
+  struct b;
+  template <typename, typename> void c ();
+};
+template <typename T>
+template <typename, typename>
+void
+a<T>::c ()
+{
+  typedef typename T::b b; // Don't go looking inside the typename
+  T thing;
+  {
+    T thing; // { dg-warning "shadows a previous local" }
+  }
+}
+