This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Add -Wold-style-definition


"Joseph S. Myers" <jsm@polyomino.org.uk> writes:

> On Sun, 14 Sep 2003, Andreas Jaeger wrote:
>
>> +@item -Wold-style-definition @r{(C only)}
>> +@opindex Wold-style-definition
>> +Warn if an old-style function definition is used.
>
> As long as the ordering of the warning options is vaguely conceptual
> rather than alphabetical, this probably belongs nearer
> -Wstrict-prototypes, as that gives the warnings when there isn't a
> previous prototype.  (And this documentation should explicitly state that
> a warning is given even if there is a previous prototype.)  But wherever
> it goes it'll probably move if the ordering is cleaned up in future.

Ok, changed.

>> +/* Warn about old-style parameter declaration.  */
>
> Only about the parameter declarations, or also about functions defined as
>
> void
> foo ()
> {
> }
>
> (without (void))?  Those are arguably old-style definitions as well - and
> a warning should certainly be available that warns for them even if there
> is a previous prototype.

No, it does not (yet) warn about these.

>> +Wold-style-definition
>> +C ObjC
>> +Warn if an old-style style parameter definition is used
>
> Typo: "old-style style" duplicates "style".

Fixed.

>> Index: gcc/testsuite/gcc.dg/old_style_def.c
>
> We don't have clear testcase naming conventions, but I'd prefer the longer
> name Wold-style-definition-1.c (and we do reasonably consistently include
> the number suffix in case another testcase for that option is wanted in
> future - as making an existing testcase test something it didn't test
> before is bad for regression testers).

OK.

> As warning even when there is a previous prototype is what this option
> adds to -Wstrict-prototypes, the testcase should provide a previous
> prototype.  (And also test for old-style definitions without parameters,
> if those are to be included in the option.  And for old-style definitions
> where there are parameters but they all default to int instead of being
> explicitly declared.)

It does not warn for these either.

You only get the following warning:

void
bar (a) int a; { } /* { dg-warning "old-style parameter declaration" } */

void bar1 () {}

extern void bar2 (void);

void bar2 () {}

extern void bar3 (int);

void bar3 (a) {}

void bar4 (a) {}

But I guess, you'd like to see warnings for these also?  Ok, then I
need to look closer into the parser...

Thanks for your comments,
Andreas
-- 
 Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj
  SuSE Linux AG, Deutschherrnstr. 15-19, 90429 Nürnberg, Germany
   GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126

Attachment: pgp00000.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]