If you are compiling linux kernel. For example, if you want to disable the warning that is "unused-but-set-variable" been treated as error. You can add a statement:
KBUILD_CFLAGS += $(call cc-option,-Wno-error=unused-but-set-variable,)
in your Makefile