kbuild: clang: disable unused variable warnings only when constant

"Linux Kernel Mailing List" <[email protected]>
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/0a5f41767444cc3b4fc5573921ab914b4f78baaa
Commit:     0a5f41767444cc3b4fc5573921ab914b4f78baaa
Parent:     1b9eda2e4892cb373c7d4cf23439f357c8739e27
Refname:    refs/heads/master
Author:     Sodagudi Prasad <[email protected]>
AuthorDate: Tue Feb 6 15:46:51 2018 -0800
Committer:  Masahiro Yamada <[email protected]>
CommitDate: Wed Feb 7 09:20:19 2018 +0900

    kbuild: clang: disable unused variable warnings only when constant
    
    Currently, GCC disables -Wunused-const-variable, but not
    -Wunused-variable, so warns unused variables if they are
    non-constant.
    
    While, Clang does not warn unused variables at all regardless of
    the const qualifier because -Wno-unused-const-variable is implied
    by the stronger option -Wno-unused-variable.
    
    Disable -Wunused-const-variable instead of -Wunused-variable so that
    GCC and Clang work in the same way.
    
    Signed-off-by: Prasad Sodagudi <[email protected]>
    Signed-off-by: Masahiro Yamada <[email protected]>
---
 Makefile | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 11aff0f9e105..ca0a57198ca6 100644
--- a/Makefile
+++ b/Makefile
@@ -700,7 +700,6 @@ KBUILD_CFLAGS += $(stackp-flag)
 
 ifeq ($(cc-name),clang)
 KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
-KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
 KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
 KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
 KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
@@ -718,9 +717,9 @@ else
 # These warnings generated too much noise in a regular build.
 # Use make W=1 to enable them (see scripts/Makefile.extrawarn)
 KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
-KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
 endif
 
+KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
 ifdef CONFIG_FRAME_POINTER
 KBUILD_CFLAGS	+= -fno-omit-frame-pointer -fno-optimize-sibling-calls
 else
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.