public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C PATCH] Fix -Wunused-function (PR debug/66869)
@ 2016-01-25 20:38 Jakub Jelinek
  2016-01-26 15:21 ` Richard Biener
  0 siblings, 1 reply; 12+ messages in thread
From: Jakub Jelinek @ 2016-01-25 20:38 UTC (permalink / raw)
  To: Joseph S. Myers, Marek Polacek, Jason Merrill, Jan Hubicka; +Cc: gcc-patches

Hi!

The early-debug changes moved warnings about unused functions into cgraph.
The problem is that if we have just unused declarations, they aren't
sometimes even registered with cgraph and therefore we no longer warn.

Here is an attempt to register those with cgraph anyway to get the warning,
for C FE only (no idea where to do that in C++ FE).  Or anyone has better
suggestions what to do?

Bootstrapped/regtested on x86_64-linux and i686-linux.

2016-01-25  Jakub Jelinek  <jakub@redhat.com>

	PR debug/66869
	* c-decl.c (c_write_global_declarations_1): For warn_unused_function,
	ensure creation of cgraph node even if there is no definition.

	* gcc.dg/pr66869.c: New test.

--- gcc/c/c-decl.c.jj	2016-01-21 00:41:47.000000000 +0100
+++ gcc/c/c-decl.c	2016-01-25 16:36:31.973504082 +0100
@@ -10741,11 +10741,19 @@ c_write_global_declarations_1 (tree glob
       if (TREE_CODE (decl) == FUNCTION_DECL
 	  && DECL_INITIAL (decl) == 0
 	  && DECL_EXTERNAL (decl)
-	  && !TREE_PUBLIC (decl)
-	  && C_DECL_USED (decl))
+	  && !TREE_PUBLIC (decl))
 	{
-	  pedwarn (input_location, 0, "%q+F used but never defined", decl);
-	  TREE_NO_WARNING (decl) = 1;
+	  if (C_DECL_USED (decl))
+	    {
+	      pedwarn (input_location, 0, "%q+F used but never defined", decl);
+	      TREE_NO_WARNING (decl) = 1;
+	    }
+	  /* For -Wunused-function push the unused statics into cgraph,
+	     so that check_global_declaration emits the warning.  */
+	  else if (warn_unused_function
+		   && ! DECL_ARTIFICIAL (decl)
+		   && ! TREE_NO_WARNING (decl))
+	    cgraph_node::get_create (decl);
 	}
 
       wrapup_global_declaration_1 (decl);
--- gcc/testsuite/gcc.dg/pr66869.c.jj	2016-01-25 16:38:39.037758657 +0100
+++ gcc/testsuite/gcc.dg/pr66869.c	2016-01-25 16:39:42.346888954 +0100
@@ -0,0 +1,6 @@
+/* PR debug/66869 */
+/* { dg-do compile } */
+/* { dg-options "-Wunused-function" } */
+
+static void test (void); /* { dg-warning "'test' declared 'static' but never defined" } */
+int i;

	Jakub

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [C PATCH] Fix -Wunused-function (PR debug/66869)
  2016-01-25 20:38 [C PATCH] Fix -Wunused-function (PR debug/66869) Jakub Jelinek
@ 2016-01-26 15:21 ` Richard Biener
  2016-01-26 16:18   ` Jakub Jelinek
  0 siblings, 1 reply; 12+ messages in thread
From: Richard Biener @ 2016-01-26 15:21 UTC (permalink / raw)
  To: Jakub Jelinek
  Cc: Joseph S. Myers, Marek Polacek, Jason Merrill, Jan Hubicka, GCC Patches

On Mon, Jan 25, 2016 at 9:38 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> The early-debug changes moved warnings about unused functions into cgraph.
> The problem is that if we have just unused declarations, they aren't
> sometimes even registered with cgraph and therefore we no longer warn.
>
> Here is an attempt to register those with cgraph anyway to get the warning,
> for C FE only (no idea where to do that in C++ FE).  Or anyone has better
> suggestions what to do?
>
> Bootstrapped/regtested on x86_64-linux and i686-linux.
>
> 2016-01-25  Jakub Jelinek  <jakub@redhat.com>
>
>         PR debug/66869
>         * c-decl.c (c_write_global_declarations_1): For warn_unused_function,
>         ensure creation of cgraph node even if there is no definition.
>
>         * gcc.dg/pr66869.c: New test.
>
> --- gcc/c/c-decl.c.jj   2016-01-21 00:41:47.000000000 +0100
> +++ gcc/c/c-decl.c      2016-01-25 16:36:31.973504082 +0100
> @@ -10741,11 +10741,19 @@ c_write_global_declarations_1 (tree glob
>        if (TREE_CODE (decl) == FUNCTION_DECL
>           && DECL_INITIAL (decl) == 0
>           && DECL_EXTERNAL (decl)
> -         && !TREE_PUBLIC (decl)
> -         && C_DECL_USED (decl))
> +         && !TREE_PUBLIC (decl))
>         {
> -         pedwarn (input_location, 0, "%q+F used but never defined", decl);
> -         TREE_NO_WARNING (decl) = 1;
> +         if (C_DECL_USED (decl))
> +           {
> +             pedwarn (input_location, 0, "%q+F used but never defined", decl);
> +             TREE_NO_WARNING (decl) = 1;
> +           }
> +         /* For -Wunused-function push the unused statics into cgraph,
> +            so that check_global_declaration emits the warning.  */
> +         else if (warn_unused_function
> +                  && ! DECL_ARTIFICIAL (decl)
> +                  && ! TREE_NO_WARNING (decl))
> +           cgraph_node::get_create (decl);

Err, so why not warn here directly?

Richard.

>         }
>
>        wrapup_global_declaration_1 (decl);
> --- gcc/testsuite/gcc.dg/pr66869.c.jj   2016-01-25 16:38:39.037758657 +0100
> +++ gcc/testsuite/gcc.dg/pr66869.c      2016-01-25 16:39:42.346888954 +0100
> @@ -0,0 +1,6 @@
> +/* PR debug/66869 */
> +/* { dg-do compile } */
> +/* { dg-options "-Wunused-function" } */
> +
> +static void test (void); /* { dg-warning "'test' declared 'static' but never defined" } */
> +int i;
>
>         Jakub

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [C PATCH] Fix -Wunused-function (PR debug/66869)
  2016-01-26 15:21 ` Richard Biener
@ 2016-01-26 16:18   ` Jakub Jelinek
  2016-01-27 10:17     ` Richard Biener
  0 siblings, 1 reply; 12+ messages in thread
From: Jakub Jelinek @ 2016-01-26 16:18 UTC (permalink / raw)
  To: Richard Biener
  Cc: Joseph S. Myers, Marek Polacek, Jason Merrill, Jan Hubicka, GCC Patches

On Tue, Jan 26, 2016 at 04:21:08PM +0100, Richard Biener wrote:
> > --- gcc/c/c-decl.c.jj   2016-01-21 00:41:47.000000000 +0100
> > +++ gcc/c/c-decl.c      2016-01-25 16:36:31.973504082 +0100
> > @@ -10741,11 +10741,19 @@ c_write_global_declarations_1 (tree glob
> >        if (TREE_CODE (decl) == FUNCTION_DECL
> >           && DECL_INITIAL (decl) == 0
> >           && DECL_EXTERNAL (decl)
> > -         && !TREE_PUBLIC (decl)
> > -         && C_DECL_USED (decl))
> > +         && !TREE_PUBLIC (decl))
> >         {
> > -         pedwarn (input_location, 0, "%q+F used but never defined", decl);
> > -         TREE_NO_WARNING (decl) = 1;
> > +         if (C_DECL_USED (decl))
> > +           {
> > +             pedwarn (input_location, 0, "%q+F used but never defined", decl);
> > +             TREE_NO_WARNING (decl) = 1;
> > +           }
> > +         /* For -Wunused-function push the unused statics into cgraph,
> > +            so that check_global_declaration emits the warning.  */
> > +         else if (warn_unused_function
> > +                  && ! DECL_ARTIFICIAL (decl)
> > +                  && ! TREE_NO_WARNING (decl))
> > +           cgraph_node::get_create (decl);
> 
> Err, so why not warn here directly?

You mean check if it has a cgraph node (i.e. get instead of get_create) and
if it doesn't, warn?  What I'm worried in that case is that it might have a
cgraph node created later on for whatever reason and that we'll get double
warning (from here and from cgraphunit.c (check_global_declaration)).
I can try it though.

	Jakub

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [C PATCH] Fix -Wunused-function (PR debug/66869)
  2016-01-26 16:18   ` Jakub Jelinek
@ 2016-01-27 10:17     ` Richard Biener
  2016-01-27 18:52       ` Jakub Jelinek
  0 siblings, 1 reply; 12+ messages in thread
From: Richard Biener @ 2016-01-27 10:17 UTC (permalink / raw)
  To: Jakub Jelinek
  Cc: Joseph S. Myers, Marek Polacek, Jason Merrill, Jan Hubicka, GCC Patches

On Tue, Jan 26, 2016 at 5:18 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Tue, Jan 26, 2016 at 04:21:08PM +0100, Richard Biener wrote:
>> > --- gcc/c/c-decl.c.jj   2016-01-21 00:41:47.000000000 +0100
>> > +++ gcc/c/c-decl.c      2016-01-25 16:36:31.973504082 +0100
>> > @@ -10741,11 +10741,19 @@ c_write_global_declarations_1 (tree glob
>> >        if (TREE_CODE (decl) == FUNCTION_DECL
>> >           && DECL_INITIAL (decl) == 0
>> >           && DECL_EXTERNAL (decl)
>> > -         && !TREE_PUBLIC (decl)
>> > -         && C_DECL_USED (decl))
>> > +         && !TREE_PUBLIC (decl))
>> >         {
>> > -         pedwarn (input_location, 0, "%q+F used but never defined", decl);
>> > -         TREE_NO_WARNING (decl) = 1;
>> > +         if (C_DECL_USED (decl))
>> > +           {
>> > +             pedwarn (input_location, 0, "%q+F used but never defined", decl);
>> > +             TREE_NO_WARNING (decl) = 1;
>> > +           }
>> > +         /* For -Wunused-function push the unused statics into cgraph,
>> > +            so that check_global_declaration emits the warning.  */
>> > +         else if (warn_unused_function
>> > +                  && ! DECL_ARTIFICIAL (decl)
>> > +                  && ! TREE_NO_WARNING (decl))
>> > +           cgraph_node::get_create (decl);
>>
>> Err, so why not warn here directly?
>
> You mean check if it has a cgraph node (i.e. get instead of get_create) and
> if it doesn't, warn?  What I'm worried in that case is that it might have a
> cgraph node created later on for whatever reason and that we'll get double
> warning (from here and from cgraphunit.c (check_global_declaration)).
> I can try it though.

No, simply warn and set TREE_NO_WARNING so cgraph doesn't warn again.

Richard.

>         Jakub

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [C PATCH] Fix -Wunused-function (PR debug/66869)
  2016-01-27 10:17     ` Richard Biener
@ 2016-01-27 18:52       ` Jakub Jelinek
  2016-01-27 19:29         ` Jeff Law
  0 siblings, 1 reply; 12+ messages in thread
From: Jakub Jelinek @ 2016-01-27 18:52 UTC (permalink / raw)
  To: Richard Biener
  Cc: Joseph S. Myers, Marek Polacek, Jason Merrill, Jan Hubicka, GCC Patches

Hi!

On Wed, Jan 27, 2016 at 11:17:18AM +0100, Richard Biener wrote:
> No, simply warn and set TREE_NO_WARNING so cgraph doesn't warn again.

This seems to work too, bootstrapped/regtested on x86_64-linux and
i686-linux, ok for trunk?

2016-01-25  Jakub Jelinek  <jakub@redhat.com>

	PR debug/66869
	* c-decl.c (c_write_global_declarations_1): Warn with
	warn_unused_function if static prototype without definition
	is not C_DECL_USED.

	* gcc.dg/pr66869.c: New test.

--- gcc/c/c-decl.c.jj	2016-01-25 22:33:11.813025064 +0100
+++ gcc/c/c-decl.c	2016-01-27 13:03:15.896068387 +0100
@@ -10741,11 +10741,22 @@ c_write_global_declarations_1 (tree glob
       if (TREE_CODE (decl) == FUNCTION_DECL
 	  && DECL_INITIAL (decl) == 0
 	  && DECL_EXTERNAL (decl)
-	  && !TREE_PUBLIC (decl)
-	  && C_DECL_USED (decl))
+	  && !TREE_PUBLIC (decl))
 	{
-	  pedwarn (input_location, 0, "%q+F used but never defined", decl);
-	  TREE_NO_WARNING (decl) = 1;
+	  if (C_DECL_USED (decl))
+	    {
+	      pedwarn (input_location, 0, "%q+F used but never defined", decl);
+	      TREE_NO_WARNING (decl) = 1;
+	    }
+	  /* For -Wunused-function warn about unused static prototypes.  */
+	  else if (warn_unused_function
+		   && ! DECL_ARTIFICIAL (decl)
+		   && ! TREE_NO_WARNING (decl))
+	    {
+	      warning (OPT_Wunused_function,
+		       "%q+F declared %<static%> but never defined", decl);
+	      TREE_NO_WARNING (decl) = 1;
+	    }
 	}
 
       wrapup_global_declaration_1 (decl);
--- gcc/testsuite/gcc.dg/pr66869.c.jj	2016-01-27 12:59:46.997929005 +0100
+++ gcc/testsuite/gcc.dg/pr66869.c	2016-01-27 12:59:46.997929005 +0100
@@ -0,0 +1,6 @@
+/* PR debug/66869 */
+/* { dg-do compile } */
+/* { dg-options "-Wunused-function" } */
+
+static void test (void); /* { dg-warning "'test' declared 'static' but never defined" } */
+int i;


	Jakub

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [C PATCH] Fix -Wunused-function (PR debug/66869)
  2016-01-27 18:52       ` Jakub Jelinek
@ 2016-01-27 19:29         ` Jeff Law
  2016-01-28 20:15           ` [C++ " Jakub Jelinek
  0 siblings, 1 reply; 12+ messages in thread
From: Jeff Law @ 2016-01-27 19:29 UTC (permalink / raw)
  To: Jakub Jelinek, Richard Biener
  Cc: Joseph S. Myers, Marek Polacek, Jason Merrill, Jan Hubicka, GCC Patches

On 01/27/2016 11:51 AM, Jakub Jelinek wrote:
> Hi!
>
> On Wed, Jan 27, 2016 at 11:17:18AM +0100, Richard Biener wrote:
>> No, simply warn and set TREE_NO_WARNING so cgraph doesn't warn again.
>
> This seems to work too, bootstrapped/regtested on x86_64-linux and
> i686-linux, ok for trunk?
>
> 2016-01-25  Jakub Jelinek  <jakub@redhat.com>
>
> 	PR debug/66869
> 	* c-decl.c (c_write_global_declarations_1): Warn with
> 	warn_unused_function if static prototype without definition
> 	is not C_DECL_USED.
>
> 	* gcc.dg/pr66869.c: New test.
OK.
jeff

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [C++ PATCH] Fix -Wunused-function (PR debug/66869)
  2016-01-27 19:29         ` Jeff Law
@ 2016-01-28 20:15           ` Jakub Jelinek
  2016-01-29 10:25             ` Jason Merrill
  0 siblings, 1 reply; 12+ messages in thread
From: Jakub Jelinek @ 2016-01-28 20:15 UTC (permalink / raw)
  To: Jason Merrill
  Cc: Richard Biener, Joseph S. Myers, Marek Polacek, Jan Hubicka, GCC Patches

On Wed, Jan 27, 2016 at 12:28:58PM -0700, Jeff Law wrote:
> On 01/27/2016 11:51 AM, Jakub Jelinek wrote:
> >2016-01-25  Jakub Jelinek  <jakub@redhat.com>
> >
> >	PR debug/66869
> >	* c-decl.c (c_write_global_declarations_1): Warn with
> >	warn_unused_function if static prototype without definition
> >	is not C_DECL_USED.
> >
> >	* gcc.dg/pr66869.c: New test.

And here is corresponding C++ FE patch.  Bootstrapped/regtested on
x86_64-linux and i686-linux, ok for trunk?

2016-01-28  Jakub Jelinek  <jakub@redhat.com>

	PR debug/66869
	* decl.c (wrapup_globals_for_namespace): Warn about unused static
	function declarations.

	* g++.dg/warn/Wunused-function2.C: New test.

--- gcc/cp/decl.c.jj	2016-01-25 09:31:01.000000000 +0100
+++ gcc/cp/decl.c	2016-01-28 13:14:10.783286136 +0100
@@ -879,6 +879,24 @@ wrapup_globals_for_namespace (tree name_
   tree *vec = statics->address ();
   int len = statics->length ();
 
+  if (warn_unused_function)
+    {
+      tree decl;
+      unsigned int i;
+      FOR_EACH_VEC_SAFE_ELT (statics, i, decl)
+	if (TREE_CODE (decl) == FUNCTION_DECL
+	    && DECL_INITIAL (decl) == 0
+	    && DECL_EXTERNAL (decl)
+	    && !TREE_PUBLIC (decl)
+	    && !DECL_ARTIFICIAL (decl)
+	    && !TREE_NO_WARNING (decl))
+	  {
+	    warning (OPT_Wunused_function,
+		     "%q+F declared %<static%> but never defined", decl);
+	    TREE_NO_WARNING (decl) = 1;
+	  }
+    }
+
   /* Write out any globals that need to be output.  */
   return wrapup_global_declarations (vec, len);
 }
--- gcc/testsuite/g++.dg/warn/Wunused-function2.C.jj	2016-01-28 13:40:10.201053364 +0100
+++ gcc/testsuite/g++.dg/warn/Wunused-function2.C	2016-01-28 13:41:43.006788487 +0100
@@ -0,0 +1,6 @@
+// PR debug/66869
+// { dg-do compile }
+// { dg-options "-Wunused-function" }
+
+static void test (void); // { dg-warning "'void test..' declared 'static' but never defined" }
+int i;


	Jakub

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [C++ PATCH] Fix -Wunused-function (PR debug/66869)
  2016-01-28 20:15           ` [C++ " Jakub Jelinek
@ 2016-01-29 10:25             ` Jason Merrill
  2016-01-29 10:35               ` Jakub Jelinek
  0 siblings, 1 reply; 12+ messages in thread
From: Jason Merrill @ 2016-01-29 10:25 UTC (permalink / raw)
  To: Jakub Jelinek
  Cc: Richard Biener, Joseph S. Myers, Marek Polacek, Jan Hubicka, GCC Patches

On 01/28/2016 03:15 PM, Jakub Jelinek wrote:
> +	if (TREE_CODE (decl) == FUNCTION_DECL
> +	    && DECL_INITIAL (decl) == 0
> +	    && DECL_EXTERNAL (decl)
> +	    && !TREE_PUBLIC (decl)
> +	    && !DECL_ARTIFICIAL (decl)
> +	    && !TREE_NO_WARNING (decl))

Do we need to check both DECL_INITIAL and DECL_EXTERNAL?

Jason

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [C++ PATCH] Fix -Wunused-function (PR debug/66869)
  2016-01-29 10:25             ` Jason Merrill
@ 2016-01-29 10:35               ` Jakub Jelinek
  2016-01-29 10:47                 ` Jason Merrill
  2016-01-29 12:31                 ` Jakub Jelinek
  0 siblings, 2 replies; 12+ messages in thread
From: Jakub Jelinek @ 2016-01-29 10:35 UTC (permalink / raw)
  To: Jason Merrill
  Cc: Richard Biener, Joseph S. Myers, Marek Polacek, Jan Hubicka, GCC Patches

On Thu, Jan 28, 2016 at 09:51:34PM -0500, Jason Merrill wrote:
> On 01/28/2016 03:15 PM, Jakub Jelinek wrote:
> >+	if (TREE_CODE (decl) == FUNCTION_DECL
> >+	    && DECL_INITIAL (decl) == 0
> >+	    && DECL_EXTERNAL (decl)
> >+	    && !TREE_PUBLIC (decl)
> >+	    && !DECL_ARTIFICIAL (decl)
> >+	    && !TREE_NO_WARNING (decl))
> 
> Do we need to check both DECL_INITIAL and DECL_EXTERNAL?

Dunno, but that is what cgraphunit.c does, c-decl.c too,
what the old toplev.c (check_global_declaration_1) did (back to at least
r26593 from ~ 1999), so I think we want some consistency.
Either it is needed, or if it is not needed, then all the spots should
change, not just this one.
I can try to stick there an assert whether for FUNCTION_DECL
(DECL_INITIAL (decl) == 0) == DECL_EXTERNAL (decl).

	Jakub

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [C++ PATCH] Fix -Wunused-function (PR debug/66869)
  2016-01-29 10:35               ` Jakub Jelinek
@ 2016-01-29 10:47                 ` Jason Merrill
  2016-01-29 12:31                 ` Jakub Jelinek
  1 sibling, 0 replies; 12+ messages in thread
From: Jason Merrill @ 2016-01-29 10:47 UTC (permalink / raw)
  To: Jakub Jelinek
  Cc: Richard Biener, Joseph S. Myers, Marek Polacek, Jan Hubicka, GCC Patches

On 01/29/2016 11:35 AM, Jakub Jelinek wrote:
> On Thu, Jan 28, 2016 at 09:51:34PM -0500, Jason Merrill wrote:
>> On 01/28/2016 03:15 PM, Jakub Jelinek wrote:
>>> +	if (TREE_CODE (decl) == FUNCTION_DECL
>>> +	    && DECL_INITIAL (decl) == 0
>>> +	    && DECL_EXTERNAL (decl)
>>> +	    && !TREE_PUBLIC (decl)
>>> +	    && !DECL_ARTIFICIAL (decl)
>>> +	    && !TREE_NO_WARNING (decl))
>>
>> Do we need to check both DECL_INITIAL and DECL_EXTERNAL?
>
> Dunno, but that is what cgraphunit.c does, c-decl.c too,
> what the old toplev.c (check_global_declaration_1) did (back to at least
> r26593 from ~ 1999), so I think we want some consistency.

OK.

Jason


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [C++ PATCH] Fix -Wunused-function (PR debug/66869)
  2016-01-29 10:35               ` Jakub Jelinek
  2016-01-29 10:47                 ` Jason Merrill
@ 2016-01-29 12:31                 ` Jakub Jelinek
  2016-02-03 16:05                   ` Jason Merrill
  1 sibling, 1 reply; 12+ messages in thread
From: Jakub Jelinek @ 2016-01-29 12:31 UTC (permalink / raw)
  To: Jason Merrill
  Cc: Richard Biener, Joseph S. Myers, Marek Polacek, Jan Hubicka, GCC Patches

On Fri, Jan 29, 2016 at 11:35:07AM +0100, Jakub Jelinek wrote:
> I can try to stick there an assert whether for FUNCTION_DECL
> (DECL_INITIAL (decl) == 0) == DECL_EXTERNAL (decl).

Tried that, but cancelled that quickly, I see lots of cases where
DECL_INITIAL is non-NULL, but DECL_EXTERNAL is set, and some
where DECL_INITIAL is NULL, and DECL_EXTERNAL is not set,
at least in the other two spots (check_global_declaration in cgraphunit.c
and c-decl.c).  Haven't waited long enough to find out if the C++ FE is some
exception.

	Jakub

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [C++ PATCH] Fix -Wunused-function (PR debug/66869)
  2016-01-29 12:31                 ` Jakub Jelinek
@ 2016-02-03 16:05                   ` Jason Merrill
  0 siblings, 0 replies; 12+ messages in thread
From: Jason Merrill @ 2016-02-03 16:05 UTC (permalink / raw)
  To: Jakub Jelinek
  Cc: Richard Biener, Joseph S. Myers, Marek Polacek, Jan Hubicka, GCC Patches

On 01/29/2016 01:30 PM, Jakub Jelinek wrote:
> On Fri, Jan 29, 2016 at 11:35:07AM +0100, Jakub Jelinek wrote:
>> I can try to stick there an assert whether for FUNCTION_DECL
>> (DECL_INITIAL (decl) == 0) == DECL_EXTERNAL (decl).
>
> Tried that, but cancelled that quickly, I see lots of cases where
> DECL_INITIAL is non-NULL, but DECL_EXTERNAL is set, and some
> where DECL_INITIAL is NULL, and DECL_EXTERNAL is not set,
> at least in the other two spots (check_global_declaration in cgraphunit.c
> and c-decl.c).  Haven't waited long enough to find out if the C++ FE is some
> exception.

My thought was that if DECL_INITIAL is non-null, the function is 
defined, so it seems odd to warn about a lack of definition.

Jason


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-02-03 16:05 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-25 20:38 [C PATCH] Fix -Wunused-function (PR debug/66869) Jakub Jelinek
2016-01-26 15:21 ` Richard Biener
2016-01-26 16:18   ` Jakub Jelinek
2016-01-27 10:17     ` Richard Biener
2016-01-27 18:52       ` Jakub Jelinek
2016-01-27 19:29         ` Jeff Law
2016-01-28 20:15           ` [C++ " Jakub Jelinek
2016-01-29 10:25             ` Jason Merrill
2016-01-29 10:35               ` Jakub Jelinek
2016-01-29 10:47                 ` Jason Merrill
2016-01-29 12:31                 ` Jakub Jelinek
2016-02-03 16:05                   ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).