Re: [PATCH] c-family: Avoid ICEs on calls to internal functions [PR95963]

2020-06-30 Thread Richard Biener
On Tue, 30 Jun 2020, Jakub Jelinek wrote:

> Hi!
> 
> The following testcase ICEs since recent Martin's -Wnonnull changes,
> we see a CALL_EXPR and ICE because CALL_EXPR_FN is NULL, which is
> valid for internal function calls.  Internal function calls don't have a
> function type, and will never have format_arg attribute on them nor will
> serve as the i18n routines -Wformat cares about.
> 
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?

OK.

Richard.

> 2020-06-30  Jakub Jelinek  
> 
>   PR c++/95963
>   * c-common.c (check_function_arguments_recurse): Don't crash on
>   calls to internal functions.
> 
>   * g++.dg/cpp1z/launder9.C: New test.
> 
> --- gcc/c-family/c-common.c.jj2020-06-29 14:51:54.821086398 +0200
> +++ gcc/c-family/c-common.c   2020-06-29 21:06:02.624773345 +0200
> @@ -5815,7 +5815,7 @@ check_function_arguments_recurse (void (
>return;
>  }
>  
> -  if (TREE_CODE (param) == CALL_EXPR)
> +  if (TREE_CODE (param) == CALL_EXPR && CALL_EXPR_FN (param))
>  {
>tree type = TREE_TYPE (TREE_TYPE (CALL_EXPR_FN (param)));
>tree attrs;
> --- gcc/testsuite/g++.dg/cpp1z/launder9.C.jj  2020-06-29 21:07:02.191932465 
> +0200
> +++ gcc/testsuite/g++.dg/cpp1z/launder9.C 2020-06-29 21:08:19.137846260 
> +0200
> @@ -0,0 +1,11 @@
> +// PR c++/95963
> +// { dg-do compile }
> +// { dg-options "-Wnonnull" }
> +
> +struct A { virtual void foo (); };
> +
> +void
> +bar (A *p)
> +{
> +  __builtin_launder (p)->foo ();
> +}
> 
>   Jakub
> 
> 

-- 
Richard Biener 
SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)


[PATCH] c-family: Avoid ICEs on calls to internal functions [PR95963]

2020-06-30 Thread Jakub Jelinek via Gcc-patches
Hi!

The following testcase ICEs since recent Martin's -Wnonnull changes,
we see a CALL_EXPR and ICE because CALL_EXPR_FN is NULL, which is
valid for internal function calls.  Internal function calls don't have a
function type, and will never have format_arg attribute on them nor will
serve as the i18n routines -Wformat cares about.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2020-06-30  Jakub Jelinek  

PR c++/95963
* c-common.c (check_function_arguments_recurse): Don't crash on
calls to internal functions.

* g++.dg/cpp1z/launder9.C: New test.

--- gcc/c-family/c-common.c.jj  2020-06-29 14:51:54.821086398 +0200
+++ gcc/c-family/c-common.c 2020-06-29 21:06:02.624773345 +0200
@@ -5815,7 +5815,7 @@ check_function_arguments_recurse (void (
   return;
 }
 
-  if (TREE_CODE (param) == CALL_EXPR)
+  if (TREE_CODE (param) == CALL_EXPR && CALL_EXPR_FN (param))
 {
   tree type = TREE_TYPE (TREE_TYPE (CALL_EXPR_FN (param)));
   tree attrs;
--- gcc/testsuite/g++.dg/cpp1z/launder9.C.jj2020-06-29 21:07:02.191932465 
+0200
+++ gcc/testsuite/g++.dg/cpp1z/launder9.C   2020-06-29 21:08:19.137846260 
+0200
@@ -0,0 +1,11 @@
+// PR c++/95963
+// { dg-do compile }
+// { dg-options "-Wnonnull" }
+
+struct A { virtual void foo (); };
+
+void
+bar (A *p)
+{
+  __builtin_launder (p)->foo ();
+}

Jakub