public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: feature request - unused arguments
@ 2002-07-23  6:28 Robert Dewar
  2002-07-23  7:20 ` Momchil Velikov
  0 siblings, 1 reply; 6+ messages in thread
From: Robert Dewar @ 2002-07-23  6:28 UTC (permalink / raw)
  To: Steven_Shaw, gcc

<<Please can someone add a warning for unused arguments in C and C++. It would be
much appreciated.
>>

We have this feature in Ada (GNAT) and we definitely find it useful. However
we also found it important to add

   pragma Unreferenced (entity);

that would note that an entity (most often an argument) is deliberately
unreferenced.

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

* Re: feature request - unused arguments
  2002-07-23  6:28 feature request - unused arguments Robert Dewar
@ 2002-07-23  7:20 ` Momchil Velikov
  0 siblings, 0 replies; 6+ messages in thread
From: Momchil Velikov @ 2002-07-23  7:20 UTC (permalink / raw)
  To: Robert Dewar; +Cc: Steven_Shaw, gcc

>>>>> "Robert" == Robert Dewar <dewar@gnat.com> writes:

Robert> <<Please can someone add a warning for unused arguments in C and C++. It would be
Robert> much appreciated.
>>> 

Robert> We have this feature in Ada (GNAT) and we definitely find it useful. However
Robert> we also found it important to add

Robert>    pragma Unreferenced (entity);

Robert> that would note that an entity (most often an argument) is deliberately
Robert> unreferenced.

$ cat > x.c
int foo (int x, int y) { return x; }
$ gcc -c -W -Wunused x.c
x.c: In function `foo':
x.c:1: warning: unused parameter `y'
$ gcc --version
2.95.4
$ 

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

* Re: feature request - unused arguments
  2002-07-24  1:05 Steven_Shaw
@ 2002-07-24  1:42 ` Joe Buck
  0 siblings, 0 replies; 6+ messages in thread
From: Joe Buck @ 2002-07-24  1:42 UTC (permalink / raw)
  To: Steven_Shaw; +Cc: velco, gcc

[ warnings for unused parameters ]
> I did find a case where it doesn't work:
> 
> $ cat foo.cc
> struct foo1 {
>     int plus(int a, int b) {
>         return a + a;
>     }
> };
> $ g++ -W -Wall -c foo.cc
> $

Yes, some checks on inline functions aren't performed unless the function
is called.


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

* Re: feature request - unused arguments
@ 2002-07-24  1:05 Steven_Shaw
  2002-07-24  1:42 ` Joe Buck
  0 siblings, 1 reply; 6+ messages in thread
From: Steven_Shaw @ 2002-07-24  1:05 UTC (permalink / raw)
  To: velco; +Cc: gcc



>>>>>> "Robert" == Robert Dewar <dewar@gnat.com> writes:
>
>Robert> <<Please can someone add a warning for unused arguments in C and C++.
It would be
>Robert> much appreciated.
>>>>
>
>Robert> We have this feature in Ada (GNAT) and we definitely find it useful.
However
>Robert> we also found it important to add
>
>Robert>    pragma Unreferenced (entity);
>
>Robert> that would note that an entity (most often an argument) is deliberately
>Robert> unreferenced.
>
>$ cat > x.c
>int foo (int x, int y) { return x; }
>$ gcc -c -W -Wunused x.c
>x.c: In function `foo':
>x.c:1: warning: unused parameter `y'
>$ gcc --version
>2.95.4
>$

Ah. Thanks. It's not clear that  -W is need in addition to -Wall. The doco for
-Wall
states "All of the above -W options combined" which includes -Wunused-parameter.

I did find a case where it doesn't work:

$ cat foo.cc
struct foo1 {
    int plus(int a, int b) {
        return a + a;
    }
};
$ g++ -W -Wall -c foo.cc
$

Cheers, Steve.


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

* Re: feature request - unused arguments
  2002-07-23  5:18 Steven_Shaw
@ 2002-07-23  6:04 ` Gerald Pfeifer
  0 siblings, 0 replies; 6+ messages in thread
From: Gerald Pfeifer @ 2002-07-23  6:04 UTC (permalink / raw)
  To: Steven_Shaw; +Cc: gcc

On Tue, 23 Jul 2002 Steven_Shaw@adc.com wrote:
> Please can someone add a warning for unused arguments in C and C++. It
> would be much appreciated.

It's already there. Please read the docs, for example at

http://gcc.gnu.org/onlinedocs/gcc-3.1/gcc/Warning-Options.html#Warning%20Options

and search for "unused".

Gerald
-- 
Gerald "Jerry" pfeifer@dbai.tuwien.ac.at http://www.dbai.tuwien.ac.at/~pfeifer/

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

* feature request - unused arguments
@ 2002-07-23  5:18 Steven_Shaw
  2002-07-23  6:04 ` Gerald Pfeifer
  0 siblings, 1 reply; 6+ messages in thread
From: Steven_Shaw @ 2002-07-23  5:18 UTC (permalink / raw)
  To: gcc



Please can someone add a warning for unused arguments in C and C++. It would be
much appreciated.

********************
Copyright 2002 ADC Telecommunications, Inc. This communication is
the property of ADC and may contain information confidential and/or
privileged.  This communication has been transmitted for the exclusive
use of the intended recipient.  If you are not the intended recipient,
please send a copy of it with the title "Received in error" to
ssd_support_centre@adc.com and then delete the email and destroy
any copies of it.  You may not otherwise distribute, copy, or use this
communication or the information in it in any manner.  Please contact
ADC at 780 431-6565 if you need assistance. Thank you for your cooperation.


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

end of thread, other threads:[~2002-07-24  1:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-23  6:28 feature request - unused arguments Robert Dewar
2002-07-23  7:20 ` Momchil Velikov
  -- strict thread matches above, loose matches on Subject: below --
2002-07-24  1:05 Steven_Shaw
2002-07-24  1:42 ` Joe Buck
2002-07-23  5:18 Steven_Shaw
2002-07-23  6:04 ` Gerald Pfeifer

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).