From: Nathan Sidwell Date: Fri, 6 Oct 2017 16:02:13 +0000 (+0000) Subject: [PR c++/82424] Dont convert dependent types X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9db84ecedae899c04ac693d970120a065c58350e;p=gcc.git [PR c++/82424] Dont convert dependent types 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ea0e8b6f9c8..b2813ebf211 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-10-06 Nathan Sidwell + + PR c++/82424 + * name-lookup.c (check_local_shadow): Don't try and convert + dependent types. + 2017-10-06 Jakub Jelinek PR c++/82299 diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index fb86310c884..a3da34d7549 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d7af2a93b5a..97825c3319c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-10-06 Nathan Sidwell + + PR c++/82424 + * g++.dg/warn/pr82424.C: New. + 2017-10-06 Jakub Jelinek 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 index 00000000000..43dd5e4e3d2 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/pr82424.C @@ -0,0 +1,20 @@ +// { dg-additional-options "-Wshadow=compatible-local" } + +// pr c++/82424 we were trying to convert between dependent types. +template class a +{ + struct b; + template void c (); +}; +template +template +void +a::c () +{ + typedef typename T::b b; // Don't go looking inside the typename + T thing; + { + T thing; // { dg-warning "shadows a previous local" } + } +} +