From patchwork Sat May 26 23:24:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 161511 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id C648EB6F9A for ; Sun, 27 May 2012 09:26:12 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1338679574; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Message-ID:Date:From:User-Agent:MIME-Version: To:CC:Subject:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=Y3a9/hDiX2ZtVBm4naakMiSz684=; b=iTXfnJzFIgOUvn2 NY8oYgHDODjhcX8chdXvZzyxhrWPM74qsa6L+vnP2PdJapbuZ9wPGdDKuU9UvOfN qb7BkhzS1KmfylZyHCgGZRtxMLO4rVYIRWnBa53apF9A+2P5o2dmFKCFoU//m5CC ECI/+4GNu66teecyA7sqvVIc5Jtc= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=OMLCv+Vvvs/OAufSJ7h/UtVdaS5V9N8H/QOwsOV69JYYFl+ml6CmVO5Qjzm/d0 I4/viCQ6RHLSn/NuofmCXdt/HM8lbzfRkFDqfd8LiGGNXdtTx9mWsobO3cnBike5 wCrqlFmKZ7JqaALUTu/Y/Yrc1W0vvyTEACSsMgUq20cfg=; Received: (qmail 25379 invoked by alias); 26 May 2012 23:26:09 -0000 Received: (qmail 25369 invoked by uid 22791); 26 May 2012 23:26:08 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_W, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from rcsinet15.oracle.com (HELO rcsinet15.oracle.com) (148.87.113.117) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 26 May 2012 23:25:55 +0000 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q4QNPrTB027923 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 26 May 2012 23:25:54 GMT Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q4QNPr3b019373 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 26 May 2012 23:25:53 GMT Received: from abhmt105.oracle.com (abhmt105.oracle.com [141.146.116.57]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q4QNPqvI012755; Sat, 26 May 2012 18:25:52 -0500 Received: from [192.168.1.4] (/79.51.25.190) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 26 May 2012 16:25:52 -0700 Message-ID: <4FC16636.9080105@oracle.com> Date: Sun, 27 May 2012 01:24:38 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120421 Thunderbird/12.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 25137 (no -Wmissing-braces in -Wall version) X-IsSubscribed: yes 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 ... and this is the version of the patch which simply takes -Wmissing-braces out of -Wall in C++. Bootstrapped and tested all C-family languages x86-64-linux. Paolo. /////////////////// Index: doc/invoke.texi =================================================================== --- doc/invoke.texi (revision 187916) +++ doc/invoke.texi (working copy) @@ -3090,7 +3090,7 @@ Options} and @ref{Objective-C and Objective-C++ Di -Wformat @gol -Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)} @gol -Wmaybe-uninitialized @gol --Wmissing-braces @gol +-Wmissing-braces @r{(only for C/ObjC)} @gol -Wnonnull @gol -Wparentheses @gol -Wpointer-sign @gol @@ -3401,7 +3401,8 @@ or @option{-Wpedantic}. @opindex Wno-missing-braces Warn if an aggregate or union initializer is not fully bracketed. In the following example, the initializer for @samp{a} is not fully -bracketed, but that for @samp{b} is fully bracketed. +bracketed, but that for @samp{b} is fully bracketed. This warning is +enabled by @option{-Wall} in C. @smallexample int a[2][2] = @{ 0, 1, 2, 3 @}; Index: c-family/c-opts.c =================================================================== --- c-family/c-opts.c (revision 187916) +++ c-family/c-opts.c (working copy) @@ -370,7 +370,6 @@ c_common_handle_option (size_t scode, const char * c_family_lang_mask, kind, loc, handlers, global_dc); warn_char_subscripts = value; - warn_missing_braces = value; warn_parentheses = value; warn_return_type = value; warn_sequence_point = value; /* Was C only. */ @@ -402,6 +401,8 @@ c_common_handle_option (size_t scode, const char * done in c_common_post_options. */ if (warn_enum_compare == -1) warn_enum_compare = value; + + warn_missing_braces = value; } else { Index: testsuite/g++.dg/warn/Wbraces4.C =================================================================== --- testsuite/g++.dg/warn/Wbraces4.C (revision 0) +++ testsuite/g++.dg/warn/Wbraces4.C (revision 0) @@ -0,0 +1,34 @@ +// PR c++/25137 +// { dg-options "-Wmissing-braces" } + +struct S { int s[3]; }; +S s1 = { 1, 1, 1 }; // { dg-warning "missing braces" } + +struct S1 { int s[3]; }; +struct S2 { struct S1 a; }; +S2 s21 = { 1, 1, 1 }; // { dg-warning "missing braces" } + +struct S3 { int s[3]; }; +struct S4 { struct S3 a; int b; }; +S4 s41 = { 1, 1, 1, 1 }; // { dg-warning "missing braces" } + +struct S5 { int s[3]; }; +struct S6 { struct S5 a; int b; }; +S6 s61 = { { 1, 1, 1 }, 1 }; // { dg-warning "missing braces" } + +struct S7 { int s[3]; }; +struct S8 { int a; struct S7 b; }; +S8 s81 = { 1, { 1, 1, 1 } }; // { dg-warning "missing braces" } + +struct S9 { int s[2]; }; +struct S10 { struct S9 a; struct S9 b; }; +S10 s101 = { { 1, 1 }, 1, 1 }; // { dg-warning "missing braces" } + +struct S11 { int s[2]; }; +struct S12 { struct S11 a; struct S11 b; }; +S12 s121 = { { 1, 1 }, { 1, 1 } }; // { dg-warning "missing braces" } + +struct S13 { int i; }; +struct S14 { struct S13 a; }; +struct S15 { struct S14 b; }; +S15 s151 = { 1 }; // { dg-warning "missing braces" } Index: testsuite/g++.dg/warn/Wbraces3.C =================================================================== --- testsuite/g++.dg/warn/Wbraces3.C (revision 0) +++ testsuite/g++.dg/warn/Wbraces3.C (revision 0) @@ -0,0 +1,34 @@ +// PR c++/25137 +// { dg-options "-Wall" } + +struct S { int s[3]; }; +S s1 = { 1, 1, 1 }; + +struct S1 { int s[3]; }; +struct S2 { struct S1 a; }; +S2 s21 = { 1, 1, 1 }; + +struct S3 { int s[3]; }; +struct S4 { struct S3 a; int b; }; +S4 s41 = { 1, 1, 1, 1 }; + +struct S5 { int s[3]; }; +struct S6 { struct S5 a; int b; }; +S6 s61 = { { 1, 1, 1 }, 1 }; + +struct S7 { int s[3]; }; +struct S8 { int a; struct S7 b; }; +S8 s81 = { 1, { 1, 1, 1 } }; + +struct S9 { int s[2]; }; +struct S10 { struct S9 a; struct S9 b; }; +S10 s101 = { { 1, 1 }, 1, 1 }; + +struct S11 { int s[2]; }; +struct S12 { struct S11 a; struct S11 b; }; +S12 s121 = { { 1, 1 }, { 1, 1 } }; + +struct S13 { int i; }; +struct S14 { struct S13 a; }; +struct S15 { struct S14 b; }; +S15 s151 = { 1 };