Hi,

this fixes an unexprected fallout from my previous patch on the 
-Wshadow=complatible-local.

By using can_convert_arg here, it avoids the issue, that can_convert tries to 
cast
int() to char*, which is a a possible NULL-pointer value in C++98 (but not in 
C++11).
As pointed out in the PR, there are still more issues with can_convert, but I 
would
like to fix the regression here without digging any deeper in the mud, at least 
for now.


Boot-strapped and reg-tested on x86_64-pc-linux-gnu.
Is it OK for trunk?


Thanks
Bernd.
2019-11-08  Bernd Edlinger  <bernd.edlin...@hotmail.de>

	PR c++/92365
	* name-lookup.c (check_local_shadow): Use can_convert_arg
	instead of can_convert.

testsuite:
2019-11-08  Bernd Edlinger  <bernd.edlin...@hotmail.de>

	PR c++/92365
	* g++.dg/pr92365.C: New test.

Index: gcc/cp/name-lookup.c
===================================================================
--- gcc/cp/name-lookup.c	(revision 277860)
+++ gcc/cp/name-lookup.c	(working copy)
@@ -2770,8 +2770,8 @@ check_local_shadow (tree decl)
 		      (now) doing the shadow checking too
 		      early.  */
 		   && !type_uses_auto (TREE_TYPE (decl))
-		   && can_convert (TREE_TYPE (old), TREE_TYPE (decl),
-				   tf_none)))
+		   && can_convert_arg (TREE_TYPE (old), TREE_TYPE (decl),
+				       decl, LOOKUP_IMPLICIT, tf_none)))
 	warning_code = OPT_Wshadow_compatible_local;
       else
 	warning_code = OPT_Wshadow_local;
Index: gcc/testsuite/g++.dg/pr92365.C
===================================================================
--- gcc/testsuite/g++.dg/pr92365.C	(revision 0)
+++ gcc/testsuite/g++.dg/pr92365.C	(working copy)
@@ -0,0 +1,12 @@
+/* PR c++/92365  */
+/* { dg-options "-std=c++98 -Wshadow=compatible-local" } */
+
+class a {
+public:
+  a(char *);
+};
+void b() {
+  a c(0);
+  if (0)
+    int c;
+}

Reply via email to