Re: [PATCH] Fix PR c++/92365

2019-11-18 Thread Jason Merrill

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.



[PING] [PATCH] Fix PR c++/92365

2019-11-15 Thread Bernd Edlinger
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.
> 


[PATCH] Fix PR c++/92365

2019-11-08 Thread Bernd Edlinger
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  

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

testsuite:
2019-11-08  Bernd Edlinger  

	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;
+}