From patchwork Fri Jun 16 13:47:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 776767 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wq1s70Sf2z9s7m for ; Fri, 16 Jun 2017 23:47:38 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="YSv2ysG1"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=SXeKUJ9d4NbTA6ipVOsM1c1jyXA5G1Gtlu//VMcPzOsiUJiWhy F7dGAosxV2C9nOt/jqxKV21nAWBN6fJTKjkR0+QKHyp5xEUcTSl8LZG2oq3xwD3e JK5o77xq32QMOSsz9pJQ9vt0BSikOXlv93sGLsNuefSCM3Lq526rakTZ4= 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:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=p0Jt14HfeWXW80iqqZkAzWyBjPg=; b=YSv2ysG1aa4jwCFHORSS yF20Wvw+1gJA1pxjZo1HRcivPtvVAeDLWGczHj99e6HqHdZDBRWzjH2DRJHcDLCF 3SPO5lBTXvWJ3cWYQh63849mr4hW1YiAGDFJRPknxCFT/APelo9S+8WypLavdklL nJ7GO+glCiHozKkLwXfTIfE= Received: (qmail 31893 invoked by alias); 16 Jun 2017 13:47:22 -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 31865 invoked by uid 89); 16 Jun 2017 13:47:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: aserp1040.oracle.com Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 16 Jun 2017 13:47:19 +0000 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v5GDlLRK018872 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 16 Jun 2017 13:47:22 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v5GDlLJo012496 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 16 Jun 2017 13:47:21 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v5GDlKas007885; Fri, 16 Jun 2017 13:47:20 GMT Received: from [192.168.1.4] (/79.52.196.45) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 16 Jun 2017 06:47:20 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] PR 64644 (""warning: anonymous union with no members" should be an error with -pedantic-errors") Message-ID: <6eeb9ea6-4b55-99be-06d4-aa141df2f9f2@oracle.com> Date: Fri, 16 Jun 2017 15:47:17 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, submitter and Manuel analyzed this a while ago and came to the conclusion - which I think is still valid vs the current working draft - that strictly speaking this kind of code violates [dcl.dcl], thus a pedwarn seems more suited than a plain warning. The below one-liner, suggested by Manuel at the time, passes testing on x86_64-linux together with my testsuite changes. Thanks, Paolo. ////////////////////// /cp 2017-06-16 Manuel Lopez-Ibanez Paolo Carlini PR c++/64644 * decl2.c (finish_anon_union): Complain about "anonymous union with no members" with a pedwarn. /testsuite 2017-06-16 Manuel Lopez-Ibanez Paolo Carlini PR c++/64644 * g++.dg/other/anon-union4.C: New. * g++.old-deja/g++.law/union4.C: Adjust. * g++.old-deja/g++.other/anon1.C: Likewise. Index: cp/decl2.c =================================================================== --- cp/decl2.c (revision 249233) +++ cp/decl2.c (working copy) @@ -1559,7 +1559,7 @@ finish_anon_union (tree anon_union_decl) return; if (main_decl == NULL_TREE) { - warning (0, "anonymous union with no members"); + pedwarn (input_location, 0, "anonymous union with no members"); return; } Index: testsuite/g++.dg/other/anon-union4.C =================================================================== --- testsuite/g++.dg/other/anon-union4.C (revision 0) +++ testsuite/g++.dg/other/anon-union4.C (working copy) @@ -0,0 +1,3 @@ +// PR c++/64644 + +static union { }; // { dg-error "anonymous union with no members" } Index: testsuite/g++.old-deja/g++.law/union4.C =================================================================== --- testsuite/g++.old-deja/g++.law/union4.C (revision 249233) +++ testsuite/g++.old-deja/g++.law/union4.C (working copy) @@ -10,4 +10,4 @@ static union { struct SS { int ss; }; -};// { dg-warning "no members" } +};// { dg-error "no members" } Index: testsuite/g++.old-deja/g++.other/anon1.C =================================================================== --- testsuite/g++.old-deja/g++.other/anon1.C (revision 249233) +++ testsuite/g++.old-deja/g++.other/anon1.C (working copy) @@ -3,4 +3,4 @@ static union { union { }; -}; // { dg-warning "" } anonymous union with no members +}; // { dg-error "" } anonymous union with no members