This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] c/55976 -Werror=return-type should error on returning a value from a void function
- From: Martin Liška <mliska at suse dot cz>
- To: dave dot pagan at oracle dot com, "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 7 Jun 2018 13:19:38 +0200
- Subject: Re: [PATCH] c/55976 -Werror=return-type should error on returning a value from a void function
- References: <ccc21947-dd32-0f0a-8aa3-70ae9e255423@oracle.com> <e55ee282-32d6-6b51-72e8-06044a7e7af5@redhat.com> <CAMe9rOo-MOexfiwrCSSjXdEDjXbLGKKZMQmOmb3-+qRpA2ZM2w@mail.gmail.com> <a9e1e95e-9c7e-4fe5-6d58-aa404053030b@oracle.com>
On 06/01/2018 11:08 PM, dave.pagan@oracle.com wrote:
> Thanks for pointing this out. I'll check out what's going on and fix the issue
>
> --Dave
Hi.
Difference is in between C and C++ FEs:
marxin@marxinbox:/dev/shm/objdir/gcc> ./xgcc -B. /home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/noncompile/pr55976-1.c
/home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/noncompile/pr55976-1.c: In function ‘t’:
/home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/noncompile/pr55976-1.c:7:20: warning: ‘return’ with a value, in function returning void
void t () { return 1; } /* { dg-error "return" "function returning void" } */
^
/home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/noncompile/pr55976-1.c:7:6: note: declared here
void t () { return 1; } /* { dg-error "return" "function returning void" } */
^
/home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/noncompile/pr55976-1.c: In function ‘b’:
/home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/noncompile/pr55976-1.c:8:12: warning: ‘return’ with no value, in function returning non-void
int b () { return; } /* { dg-error "return" "function returning non-void" } */
^~~~~~
/home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/noncompile/pr55976-1.c:8:5: note: declared here
int b () { return; } /* { dg-error "return" "function returning non-void" } */
^
marxin@marxinbox:/dev/shm/objdir/gcc> ./xg++ -B. /home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/noncompile/pr55976-1.c
/home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/noncompile/pr55976-1.c: In function ‘void t()’:
/home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/noncompile/pr55976-1.c:7:20: error: return-statement with a value, in function returning ‘void’ [-fpermissive]
void t () { return 1; } /* { dg-error "return" "function returning void" } */
^
/home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/noncompile/pr55976-1.c: In function ‘int b()’:
/home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/noncompile/pr55976-1.c:8:12: error: return-statement with no value, in function returning ‘int’ [-fpermissive]
int b () { return; } /* { dg-error "return" "function returning non-void" } */
^~~~~~
Martin