lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> I get a few warnings with gcc 7.3.0.
> 
> gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_3 -DLUA_USE_LINUX
> -c -o lcode.o lcode.c
> In file included from lcode.h:12:0,
>                  from lcode.c:19:
> lcode.c: In function ‘luaK_finish’:
> lopcodes.h:108:30: warning: this statement may fall through
> [-Wimplicit-fallthrough=]
>  #define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \
>                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    ((cast(Instruction, o)<<POS_OP)&MASK1(SIZE_OP,POS_OP))))
>    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> lcode.c:1698:9: note: in expansion of macro ‘SET_OPCODE’
>          SET_OPCODE(*pc, OP_RETURN);
>          ^~~~~~~~~~
> lcode.c:1701:7: note: here
>        case OP_RETURN: case OP_TAILCALL: {
>        ^~~~

Well, fallthrough is a regular part of C. When we write

  case A:  case B: { ... }

we have a fallthrough, too. That code in Lua has an explicit comment
/* FALLTHROUGH */ there, to satisfy lint. What else does gcc 7.3 need
to be happy?

BTW, there are many other cases of fallthroughs in the code. Why gcc
only complained about those two?

-- Roberto