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: [PATCH] c/55976 -Werror=return-type should error on returning a value from a void function


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


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