[PATCH] [FIX PR c/48116] -Wreturn-type does not work as advertised

Prasad Ghangal prasad.ghangal@gmail.com
Mon Apr 25 20:06:00 GMT 2016


On 11 April 2016 at 20:09, Prasad Ghangal <prasad.ghangal@gmail.com> wrote:
>
> Hi!
>
> This is proposed patch for
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48116 (-Wreturn-type does
> not work as advertised)
>
> Currently gcc doesn't give any warning with -Wreturn-type or -Wall
> option for test cases like :
>
> void x (void) { }
> void y(void) { return x(); }
>
>
> applying this patch gives:
>
> $gcc foo.c -S -Wreturn-type
> foo.c: In function ‘y’:
> foo.c:2:23: warning: ISO C forbids ‘return’ with expression, in
> function returning void [-Wreturn-type]
>  void y(void) { return x(); }
>                        ^~~
> foo.c:2:6: note: declared here
>  void y(void) { return x(); }
>       ^
>
> $gcc foo.c -S -Wall
> foo.c: In function ‘y’:
> foo.c:2:23: warning: ISO C forbids ‘return’ with expression, in
> function returning void [-Wreturn-type]
>  void y(void) { return x(); }
>                        ^~~
> foo.c:2:6: note: declared here
>  void y(void) { return x(); }
>       ^
>
> $gcc foo.c -S -pedantic
> foo.c: In function ‘y’:
> foo.c:2:23: warning: ISO C forbids ‘return’ with expression, in
> function returning void [-Wpedantic]
>  void y(void) { return x(); }
>                        ^~~
> foo.c:2:6: note: declared here
>  void y(void) { return x(); }
>       ^
>
>
> I have fully bootstrapped and tested on x86_64-pc-linux.
>
>
>
> Thanks,
> Prasad Ghangal



*PING*

https://gcc.gnu.org/ml/gcc-patches/2016-04/msg00474.html

Is this patch OK for gcc 7?


Thanks,
Prasad Ghangal



More information about the Gcc-patches mailing list