You can use the following command to get an WARN_OPTS variable suitable for injecting directly into your Makefile:
gcc --help=warnings | awk ' BEGIN { print "WARN_OPTS = \\" } /-W[^ ]/ { print $1" \\"} ' | sed 's/^-W/ -Wno-/' >makefile.inject
This gives you output (in makefile.inject) like:
WARN_OPTS = \ -Wno- \ -Wno-abi \ -Wno-address \ -Wno-aggregate-return \ -Wno-aliasing \ -Wno-align-commons \ -Wno-all \ -Wno-ampersand \ -Wno-array-bounds \ -Wno-array-temporaries \ : : : -Wno-variadic-macros \ -Wno-vector-operation-performance \ -Wno-vla \ -Wno-volatile-register-var \ -Wno-write-strings \ -Wno-zero-as-null-pointer-constant \
Once that's put in your actual Makefile, simply use $(WARN_OPTS) as part of your gcc command.
It may need a small amount of touch up to:
- get rid of invalid options such as
-Wno-; - fix certain
-Wno-<key>=<value> types; and - remove the final
\ character.
but that's minimal effort compared to the generation of the long list, something you can now do rather simply.
When you establish that you want one of those warnings, simply switch from the -Wno-<something> back to -W<something>.
-Wreturn-type(no other warning-related flags), doesn't that do what you want?