From patchwork Mon Jan 22 09:36:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Franz Sirl X-Patchwork-Id: 864198 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-471779-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="nH7r8+kh"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zQ5sy6rYvz9sBW for ; Mon, 22 Jan 2018 20:36:37 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=mxNFUiLky5LXtkcg2zTKg5r+kIlyePx+gngBko9NX6SioCfWMf +KEoWPKbHWXa22IB7gXOrRaV8yHMlwl72wdJBxInA1F6GQlziZp1bOTvpb5tPyxd x+6+LlhqUyf/n1TT/55IwVHIwMdiAiiyn1vaOqxWzhCHVygW8M4Zaxkqk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=ING9EHCkfbb4OigSW7UtM/Rt1oQ=; b=nH7r8+khJwf6npo7b0kG KMZLWeUbIU45PPxWcxeD3PsAJAtrkYuLo3eQOvzxx/1PIRTcUrbNHwcwHCkrtn2Z eopPWCqK6Rpo754GmDr/MM92oqXFUenXpLGqQXPP4WFi1H4gxsYtMJIiFJ/ur4LT k2EGv+z4/Ho036ejIMIYxC4= Received: (qmail 128518 invoked by alias); 22 Jan 2018 09:36:30 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 128498 invoked by uid 89); 22 Jan 2018 09:36:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=H*UA:58.0, H*r:envelope-sender, UD:c-decl.c, c-decl.c X-HELO: smtp1.lauterbach.com Received: from smtp1.lauterbach.com (HELO smtp1.lauterbach.com) (62.154.241.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 22 Jan 2018 09:36:24 +0000 Received: (qmail 17233 invoked by uid 484); 22 Jan 2018 09:36:21 -0000 X-Qmail-Scanner-Diagnostics: from 10.2.11.10 by smtp1.lauterbach.com (envelope-from , uid 484) with qmail-scanner-2.11 (mhr: 1.0. clamdscan: 0.99/21437. spamassassin: 3.4.0. Clear:RC:1(10.2.11.10):. Processed in 0.416932 secs); 22 Jan 2018 09:36:21 -0000 Received: from unknown (HELO [10.2.11.10]) (Authenticated_SSL:fsirl@[10.2.11.10]) (envelope-sender ) by smtp1.lauterbach.com (qmail-ldap-1.03) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 22 Jan 2018 09:36:20 -0000 To: GCC Patches From: Franz Sirl Subject: [PATCH] Minor warning option sync with clang Message-ID: Date: Mon, 22 Jan 2018 10:36:20 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:58.0) Gecko/20100101 Thunderbird/58.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, a mail in the gcc-list https://gcc.gnu.org/ml/gcc/2018-01/msg00144.html reminded me about this minor stuff I have (so it can be controlled by -Werror), but never managed to write testcases. I'm posting it here in case it's good enough or someone wants to take over from here. Franz c/ChangeLog; 2018-01-22  Franz Sirl      * c-decl.c (grokdeclarator): Use OPT_Wextern_initializer.     * c-typeck.c (build_binary_op): Use     OPT_Wcompare_distinct_pointer_types. c-family/ChangeLog: 2018-01-22  Franz Sirl      * c.opt (-Wcompare-distinct-pointer-types): New option.     (-Wextern-initializer): Likewise. cp/ChangeLog: 2018-01-22  Franz Sirl      * decl.c (grokdeclarator): Use OPT_Wextern_initializer.     * typeck.c (composite_pointer_error): Use     OPT_Wcompare_distinct_pointer_types. Index: gcc-trunk/gcc/c-family/c.opt =================================================================== --- gcc-trunk/gcc/c-family/c.opt (revision 256939) +++ gcc-trunk/gcc/c-family/c.opt (working copy) @@ -318,10 +318,6 @@ alloca, and on bounded uses of alloca whose bound can be larger than bytes. -Warray-bounds -LangEnabledBy(C ObjC C++ ObjC++,Wall) -; in common.opt - Warray-bounds= LangEnabledBy(C ObjC C++ ObjC++,Wall,1,0) ; in common.opt @@ -420,6 +416,10 @@ C ObjC C++ ObjC++ Warning Alias(Wcomment) Synonym for -Wcomment. +Wcompare-distinct-pointer-types +C ObjC C++ ObjC++ Var(warn_distinct_pointer_types) Init(1) Warning +Warn for comparison of distinct pointer types. + Wconditionally-supported C++ ObjC++ Var(warn_conditionally_supported) Warning Warn for conditionally-supported constructs. @@ -512,6 +512,10 @@ C ObjC RejectNegative Warning Alias(Werror=, implicit-function-declaration) This switch is deprecated; use -Werror=implicit-function-declaration instead. +Wextern-initializer +C ObjC C++ ObjC++ Var(warn_extern_initializer) Init(1) Warning +Warn about extern declarations with an initializer. + Wextra C ObjC C++ ObjC++ Warning ; in common.opt @@ -694,6 +698,10 @@ C C++ Common Var(warn_misleading_indentation) Warning LangEnabledBy(C C++,Wall) Warn when the indentation of the code does not reflect the block structure. +Wmisleading-indentation-ltb +C C++ Common Var(warn_misleading_indentation_ltb) Warning +Warn when the indentation of the code does not reflect the block structure. + Wmissing-braces C ObjC C++ ObjC++ Var(warn_missing_braces) Warning LangEnabledBy(C ObjC,Wall) Warn about possibly missing braces around initializers. Index: gcc-trunk/gcc/c/c-decl.c =================================================================== --- gcc-trunk/gcc/c/c-decl.c (revision 256939) +++ gcc-trunk/gcc/c/c-decl.c (working copy) @@ -5888,8 +5888,8 @@ /* It is fine to have 'extern const' when compiling at C and C++ intersection. */ if (!(warn_cxx_compat && constp)) - warning_at (loc, 0, "%qE initialized and declared %", - name); + warning_at (loc, OPT_Wextern_initializer, + "%qE initialized and declared %", name); } else error_at (loc, "%qE has both % and initializer", name); Index: gcc-trunk/gcc/cp/decl.c =================================================================== --- gcc-trunk/gcc/cp/decl.c (revision 256939) +++ gcc-trunk/gcc/cp/decl.c (working copy) @@ -12408,7 +12408,8 @@ /* It's common practice (and completely valid) to have a const be initialized and declared extern. */ if (!(type_quals & TYPE_QUAL_CONST)) - warning (0, "%qs initialized and declared %", name); + warning_at (input_location, OPT_Wextern_initializer, + "%qs initialized and declared %", name); } else { Index: gcc-trunk/gcc/c/c-typeck.c =================================================================== --- gcc-trunk/gcc/c/c-typeck.c (revision 256939) +++ gcc-trunk/gcc/c/c-typeck.c (working copy) @@ -11599,8 +11599,9 @@ else /* Avoid warning about the volatile ObjC EH puts on decls. */ if (!objc_ok) - pedwarn (location, 0, - "comparison of distinct pointer types lacks a cast"); + pedwarn (location, OPT_Wcompare_distinct_pointer_types, + "comparison of distinct pointer types " + "%qT and %qT lacks a cast", type0, type1); if (result_type == NULL_TREE) { @@ -11711,8 +11712,9 @@ int qual = ENCODE_QUAL_ADDR_SPACE (as_common); result_type = build_pointer_type (build_qualified_type (void_type_node, qual)); - pedwarn (location, 0, - "comparison of distinct pointer types lacks a cast"); + pedwarn (location, OPT_Wcompare_distinct_pointer_types, + "comparison of distinct pointer types " + "%qT and %qT lacks a cast", type0, type1); } } else if (code0 == POINTER_TYPE && null_pointer_constant_p (orig_op1)) Index: gcc-trunk/gcc/cp/typeck.c =================================================================== --- gcc-trunk/gcc/cp/typeck.c (revision 256939) +++ gcc-trunk/gcc/cp/typeck.c (working copy) @@ -453,7 +453,8 @@ switch (operation) { case CPO_COMPARISON: - emit_diagnostic (kind, input_location, 0, + emit_diagnostic (kind, input_location, + OPT_Wcompare_distinct_pointer_types, "comparison between " "distinct pointer types %qT and %qT lacks a cast", t1, t2);