[Bug c/55976] -Werror=return-type should error on returning a value from a void function

2018-06-28 Thread dave.pagan at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55976

--- Comment #15 from Dave Pagan  ---
Thanks, Paolo!

On 06/28/2018 01:44 AM, paolo.carlini at oracle dot com wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55976
>
> Paolo Carlini  changed:
>
> What|Removed |Added
> 
>   Status|ASSIGNED|RESOLVED
>   Resolution|--- |FIXED
> Target Milestone|--- |9.0
>
> --- Comment #14 from Paolo Carlini  ---
> Done. I think we can close the bug as fixed in trunk.
>

[Bug c/55976] -Werror=return-type should error on returning a value from a void function

2018-06-28 Thread paolo.carlini at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55976

Paolo Carlini  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED
   Target Milestone|--- |9.0

--- Comment #14 from Paolo Carlini  ---
Done. I think we can close the bug as fixed in trunk.

[Bug c/55976] -Werror=return-type should error on returning a value from a void function

2018-06-28 Thread paolo at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55976

--- Comment #13 from paolo at gcc dot gnu.org  ---
Author: paolo
Date: Thu Jun 28 08:42:17 2018
New Revision: 262215

URL: https://gcc.gnu.org/viewcvs?rev=262215=gcc=rev
Log:
2018-06-28  David Pagan  

PR c/55976
* gcc.dg/noncompile/pr55976-1.c: Add dg-prune-output for extraneous
message causing unexpected test FAIL.

Modified:
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gcc.dg/noncompile/pr55976-1.c

[Bug c/55976] -Werror=return-type should error on returning a value from a void function

2018-06-14 Thread dave.pagan at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55976

--- Comment #12 from Dave Pagan  ---
New test pr55976-1.c is failing due to unaccounted for extraneous output from
the compiler. Test requires addition of dg-prune-output. Adding the directive
and will send patch shortly.

[Bug c/55976] -Werror=return-type should error on returning a value from a void function

2018-05-30 Thread law at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55976

--- Comment #11 from Jeffrey A. Law  ---
Author: law
Date: Wed May 30 22:55:38 2018
New Revision: 260978

URL: https://gcc.gnu.org/viewcvs?rev=260978=gcc=rev
Log:
2018-05-30  David Pagan  

PR c/55976
* c-decl.c (grokdeclarator): Update check for return type warnings.
(start_function): Likewise.
(finish_function): Likewise.
* c-typeck.c (c_finish_return): Update check for return type warnings.
Pass OPT_Wreturn_type to pedwarn when appropriate.

PR c/55976
* c-opts.c (c_common_post_options): Set default for warn_return_type
for C++/C++ with ObjC extensions only. For C, makes it possible to
differentiate between default (no option), -Wreturn-type, and
-Wno-return-type.

PR c/55976
* gcc.dg/noncompile/pr55976-1.c: New test.
* gcc.dg/noncompile/pr55976-2.c: New test.

Added:
trunk/gcc/testsuite/gcc.dg/noncompile/pr55976-1.c
trunk/gcc/testsuite/gcc.dg/noncompile/pr55976-2.c
Modified:
trunk/gcc/c-family/ChangeLog
trunk/gcc/c-family/c-opts.c
trunk/gcc/c/ChangeLog
trunk/gcc/c/c-decl.c
trunk/gcc/c/c-typeck.c
trunk/gcc/testsuite/ChangeLog

[Bug c/55976] -Werror=return-type should error on returning a value from a void function

2018-04-26 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55976

--- Comment #10 from Jonathan Wakely  ---
(In reply to Dave Pagan from comment #6)
> Helpful update, Jonathan - did you want to follow up on this bug then? Or
> should I go ahead based on your new information?

I missed this reply, sorry. I wasn't going to do anything further so thanks for
working on it.

[Bug c/55976] -Werror=return-type should error on returning a value from a void function

2018-04-26 Thread dave.pagan at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55976

Dave Pagan  changed:

   What|Removed |Added

   Keywords||patch

--- Comment #9 from Dave Pagan  ---
Patch submitted for review:

https://gcc.gnu.org/ml/gcc-patches/2018-04/msg01034.html

[Bug c/55976] -Werror=return-type should error on returning a value from a void function

2018-03-26 Thread paolo.carlini at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55976

Paolo Carlini  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 CC|dave.pagan at oracle dot com   |
   Assignee|unassigned at gcc dot gnu.org  |dave.pagan at oracle 
dot com

--- Comment #8 from Paolo Carlini  ---
Dave is on it.

[Bug c/55976] -Werror=return-type should error on returning a value from a void function

2018-03-15 Thread lopezibanez at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55976

--- Comment #7 from Manuel López-Ibáñez  ---
My advice would be to create a new option Wreturn-pedantic. Make this
option control the pedwarns that don't have any option. Then, enable it by
default, but also make it be enabled by Wpedantic and Wreturn-type.

An alternative would be to have the default setting of Wreturn-type depend
on flag_isoc99. Then, add OPT_Wreturn_type to all those pedwarns.

On Thu, 15 Mar 2018, 16:12 dave.pagan at oracle dot com, <
gcc-bugzi...@gcc.gnu.org> wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55976
>
> --- Comment #6 from Dave Pagan  ---
> Helpful update, Jonathan - did you want to follow up on this bug then? Or
> should I go ahead based on your new information?
>
> --
> You are receiving this mail because:
> You are on the CC list for the bug.

[Bug c/55976] -Werror=return-type should error on returning a value from a void function

2018-03-15 Thread dave.pagan at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55976

--- Comment #6 from Dave Pagan  ---
Helpful update, Jonathan - did you want to follow up on this bug then? Or
should I go ahead based on your new information?

[Bug c/55976] -Werror=return-type should error on returning a value from a void function

2018-03-13 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55976

Jonathan Wakely  changed:

   What|Removed |Added

   Keywords||diagnostic

--- Comment #5 from Jonathan Wakely  ---
I thought this should be as simple as adding OPT_Wreturn_type to the relevant
warnings in c_finish_return in gcc/c/typeck-c.c

But it seems to be more complicated. In C89 mode the "does not" case is
actually controlled by -pedantic (and -pedantic-errors) and the "does" case is
controlled by -Wreturn-type. In C99 and later modes both diagnostics are
controlled by -pedantic.

So with current GCC and the default -std=gnu11 you do get two diagnostics:

ret.c: In function ‘t’:
ret.c:1:20: warning: ‘return’ with a value, in function returning void
 void t () { return 1; } /* does not error */
^
ret.c:1:6: note: declared here
 void t () { return 1; } /* does not error */
  ^
ret.c: In function ‘b’:
ret.c:2:12: warning: ‘return’ with no value, in function returning non-void
 int b () { return; }/* does */
^~
ret.c:2:5: note: declared here
 int b () { return; }/* does */
 ^

-Werror=return-type doesn't affect either of them, but -pedantic-errors does.

[Bug c/55976] -Werror=return-type should error on returning a value from a void function

2018-03-13 Thread dave.pagan at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55976

Dave Pagan  changed:

   What|Removed |Added

 CC||dave.pagan at oracle dot com

--- Comment #4 from Dave Pagan  ---
If no one is working on this, I'd like to take a look into it.

[Bug c/55976] -Werror=return-type should error on returning a value from a void function

2017-07-30 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55976

Eric Gallager  changed:

   What|Removed |Added

 CC||manu at gcc dot gnu.org

--- Comment #3 from Eric Gallager  ---
*** Bug 70502 has been marked as a duplicate of this bug. ***

[Bug c/55976] -Werror=return-type should error on returning a value from a void function

2017-07-29 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55976

Eric Gallager  changed:

   What|Removed |Added

 CC||bastien.penavayre at epitech 
dot e
   ||u

--- Comment #2 from Eric Gallager  ---
*** Bug 71743 has been marked as a duplicate of this bug. ***

[Bug c/55976] -Werror=return-type should error on returning a value from a void function

2017-07-26 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55976

Eric Gallager  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2017-07-26
 CC||egallager at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #1 from Eric Gallager  ---
-Werror=return-type might not work but -Werror -Wreturn-type does:

$ /usr/local/bin/gcc -c -Werror=return-type 55976.c
55976.c: In function ‘t’:
55976.c:3:20: warning: ‘return’ with a value, in function returning void
 void t () { return 1; } // does not error
^
55976.c:3:6: note: declared here
 void t () { return 1; } // does not error
  ^
55976.c: In function ‘b’:
55976.c:4:12: warning: ‘return’ with no value, in function returning non-void
 int b () { return; }// does
^~
55976.c:4:5: note: declared here
 int b () { return; }// does
 ^
$ /usr/local/bin/gcc -c -Werror -Wreturn-type 55976.c
55976.c: In function ‘t’:
55976.c:3:20: error: ‘return’ with a value, in function returning void
[-Werror]
 void t () { return 1; } // does not error
^
55976.c:3:6: note: declared here
 void t () { return 1; } // does not error
  ^
55976.c: In function ‘b’:
55976.c:4:12: error: ‘return’ with no value, in function returning non-void
[-Werror]
 int b () { return; }// does
^~
55976.c:4:5: note: declared here
 int b () { return; }// does
 ^
cc1: all warnings being treated as errors
$

Confirming on the basis that -Werror=return-type should work just as well as
-Werror -Wreturn-type.