Fix PR c++/92365
diff mbox series

Message ID VI1PR03MB45285ABCC0938E4BC8AFAA69E47B0@VI1PR03MB4528.eurprd03.prod.outlook.com
State New
Headers show
Series
  • Fix PR c++/92365
Related show

Commit Message

Bernd Edlinger Nov. 8, 2019, 5:01 p.m. UTC
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.

Comments

Bernd Edlinger Nov. 15, 2019, 3:07 p.m. UTC | #1
Hi,

I'd like to ping for this patch here:
https://gcc.gnu.org/ml/gcc-patches/2019-11/msg00639.html


Thanks
Bernd.

On 11/8/19 6:01 PM, Bernd Edlinger wrote:
> 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.
>
Jason Merrill Nov. 18, 2019, 9:05 p.m. UTC | #2
On 11/8/19 5:01 PM, Bernd Edlinger wrote:
> 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.
> 
OK.

Patch
diff mbox series

2019-11-08  Bernd Edlinger  <bernd.edlinger@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.edlinger@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;
+}