From patchwork Fri Oct 11 10:58:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1175113 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-510736-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="kLJafa92"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="P7F/D/u4"; 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 46qQ1c2hTqz9sNx for ; Fri, 11 Oct 2019 21:58:57 +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:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=IsYtGvq3dEBokLWe2ZgjE///0AmwMuVe1r7wqxY/xMQ1ez61hN cbyFBvK1J4a+5PLZ4leKhC3uG+5bphn0jv/mT2KtJblMUKeEa7tUMDmUCs+WqQv6 JJXUSl6XumiLwhkV0nn/icay6uGePgDGF1CMycuowxTwBcseQzhMftKPo= 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=aYPzDWkz/uE6Om3tl/C+rC5ZqZ4=; b=kLJafa92+8eoO6QxH7yQ RPJ/+41yWAjj9qK+LQF01Gk1LmOwX9f35RDddiGjwJe2MHrZwm0IxyUdctJugzLA xsjI0Feu417OBt/CWAjPy7c9kyRv8J0Aj1L6jzZTEmSwxmBvTv8Du+8LOG3kytLl BaN6VM5U5xo8Pn40pzu1OO4= Received: (qmail 111785 invoked by alias); 11 Oct 2019 10:58:50 -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 111606 invoked by uid 89); 11 Oct 2019 10:58:50 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=3, 8 X-HELO: aserp2120.oracle.com Received: from aserp2120.oracle.com (HELO aserp2120.oracle.com) (141.146.126.78) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 11 Oct 2019 10:58:48 +0000 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x9BAwgJZ021089; Fri, 11 Oct 2019 10:58:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=to : cc : from : subject : message-id : date : mime-version : content-type; s=corp-2019-08-05; bh=3esi9I2VMQlaf4yUhifVei+F2YCtr7wN7T0WupOy95M=; b=P7F/D/u4pG6/+x9mt2Dp31no9+lsLtFqNep2bxgCBqCtPgb2T+0YXmvf98NJeX8cESSP dWu4DsaGVAZlySXJTxx6i3wQ3lDWyBN7xc6haAAr1/pu4+r1Jbdy0SE6eYwTK2p0xxh6 BR7rfqrkNRSTSk//DlvT4v/rxkt6kETME2rn/JDynx30BRLsTX+QzYZwkltWNPoAYgmT vEVYiQljK9N1rELsxNLrSgUcev3UkUeojArR2lW+xWhM6O2VAuiWXZxfXrwGFinqK66v Hax4tjtB+dH9Vmu3yB+cdOBqp7Z+gDdOqySkaJdDToVsRY7HjlIEofLf6i35/qY31ztX tg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2vek4r0tvn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Oct 2019 10:58:46 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x9BAwJOt192607; Fri, 11 Oct 2019 10:58:45 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2vje2xsd47-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Oct 2019 10:58:45 +0000 Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x9BAwiRL022084; Fri, 11 Oct 2019 10:58:44 GMT Received: from [192.168.1.4] (/79.18.213.139) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 11 Oct 2019 03:58:44 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] One more DECL_SOURCE_LOCATION Message-ID: Date: Fri, 11 Oct 2019 12:58:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 X-IsSubscribed: yes Hi, another straightforward DECL_SOURCE_LOCATION (TYPE_MAIN_DECL consistent with the one I used in build_anon_union_vars. Tested x86_64-linux. Thanks, Paolo. ///////////////////// /cp 2019-10-11 Paolo Carlini * decl.c (check_tag_decl): Use DECL_SOURCE_LOCATION. /testsuite 2019-10-11 Paolo Carlini * g++.dg/cpp0x/constexpr-union5.C: Test location(s) too. * g++.dg/diagnostic/bitfld2.C: Likewise. * g++.dg/ext/anon-struct1.C: Likewise. * g++.dg/ext/anon-struct6.C: Likewise. * g++.dg/ext/flexary19.C: Likewise. * g++.dg/ext/flexary9.C: Likewise. * g++.dg/template/error17.C: Likewise. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 276845) +++ cp/decl.c (working copy) @@ -4992,7 +4992,8 @@ check_tag_decl (cp_decl_specifier_seq *declspecs, if (TREE_CODE (declared_type) != UNION_TYPE && !in_system_header_at (input_location)) - pedwarn (input_location, OPT_Wpedantic, "ISO C++ prohibits anonymous structs"); + pedwarn (DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (declared_type)), + OPT_Wpedantic, "ISO C++ prohibits anonymous structs"); } else Index: testsuite/g++.dg/cpp0x/constexpr-union5.C =================================================================== --- testsuite/g++.dg/cpp0x/constexpr-union5.C (revision 276845) +++ testsuite/g++.dg/cpp0x/constexpr-union5.C (working copy) @@ -23,16 +23,16 @@ SA((a.i == 42)); struct B { - struct { + struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct" } int h; - struct { + struct { // { dg-warning "12:ISO C\\+\\+ prohibits anonymous struct" } union { unsigned char i; int j; }; int k; - }; // { dg-warning "anonymous struct" } - }; // { dg-warning "anonymous struct" } + }; + }; int l; constexpr B(): h(1), i(2), k(3), l(4) {} Index: testsuite/g++.dg/diagnostic/bitfld2.C =================================================================== --- testsuite/g++.dg/diagnostic/bitfld2.C (revision 276845) +++ testsuite/g++.dg/diagnostic/bitfld2.C (working copy) @@ -6,4 +6,4 @@ template struct A struct {} : 2; // { dg-error "expected ';' after struct" "expected" } }; // { dg-error "ISO C.. forbids declaration" "declaration" { target *-*-* } 6 } -// { dg-error "ISO C.. prohibits anonymous" "anonymous" { target *-*-* } 6 } +// { dg-error "10:ISO C.. prohibits anonymous" "anonymous" { target *-*-* } 6 } Index: testsuite/g++.dg/ext/anon-struct1.C =================================================================== --- testsuite/g++.dg/ext/anon-struct1.C (revision 276845) +++ testsuite/g++.dg/ext/anon-struct1.C (working copy) @@ -19,7 +19,7 @@ char testD[sizeof(C::D) == sizeof(A) ? 1 : -1]; /* GNU extension. */ struct E { - struct { char z; }; /* { dg-error "prohibits anonymous structs" } */ + struct { char z; }; /* { dg-error "10:ISO C\\+\\+ prohibits anonymous structs" } */ char e; }; @@ -45,6 +45,6 @@ char testH[sizeof(H) == 2 * sizeof(A) ? 1 : -1]; /* Make sure __extension__ gets turned back off. */ struct I { - struct { char z; }; /* { dg-error "prohibits anonymous structs" } */ + struct { char z; }; /* { dg-error "10:ISO C\\+\\+ prohibits anonymous structs" } */ char i; }; Index: testsuite/g++.dg/ext/anon-struct6.C =================================================================== --- testsuite/g++.dg/ext/anon-struct6.C (revision 276845) +++ testsuite/g++.dg/ext/anon-struct6.C (working copy) @@ -3,8 +3,8 @@ struct A { struct - { + { // { dg-error "3:ISO C\\+\\+ prohibits anonymous structs" } struct { static int i; }; // { dg-error "prohibits anonymous structs|non-static data members|unnamed class" } void foo() { i; } // { dg-error "public non-static data" } - }; // { dg-error "prohibits anonymous structs" } + }; }; Index: testsuite/g++.dg/ext/flexary19.C =================================================================== --- testsuite/g++.dg/ext/flexary19.C (revision 276845) +++ testsuite/g++.dg/ext/flexary19.C (working copy) @@ -146,13 +146,13 @@ struct S16 { int i; - struct { // { dg-warning "invalid use" } + struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct|invalid use" } // A flexible array as a sole member of an anonymous struct is // rejected with an error in C mode but emits just a pedantic // warning in C++. Other than excessive pedantry there is no // reason to reject it. int a[]; - }; // { dg-warning "anonymous struct" } + }; }; struct S17 @@ -177,9 +177,9 @@ struct S19 { int i; - struct { // { dg-warning "invalid use" } + struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct|invalid use" } int j, a[]; // { dg-message "declared here" } - }; // { dg-warning "anonymous struct" } + }; }; struct S20 @@ -198,10 +198,10 @@ struct S21 static int i; typedef int A[]; - struct { // { dg-warning "invalid use" } + struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct|invalid use" } int j; A a; // { dg-message "declared here" } - }; // { dg-warning "anonymous struct" } + }; }; struct S22 @@ -215,11 +215,11 @@ struct S22 struct S23 { - struct { + struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct" } static int i; // { dg-error "static data member" } int a[]; // { dg-error "in an otherwise empty" } - }; // { dg-warning "anonymous struct" } + }; }; struct S24 @@ -296,11 +296,11 @@ union A union B { - struct { - struct { // { dg-warning "invalid use" } + struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct" } + struct { // { dg-warning "12:ISO C\\+\\+ prohibits anonymous struct|invalid use" } int i, a[]; // { dg-message "declared here" } - }; // { dg-warning "anonymous struct" } - }; // { dg-warning "anonymous struct" } + }; + }; int j; }; Index: testsuite/g++.dg/ext/flexary9.C =================================================================== --- testsuite/g++.dg/ext/flexary9.C (revision 276845) +++ testsuite/g++.dg/ext/flexary9.C (working copy) @@ -282,64 +282,64 @@ struct S_S_S_x { struct Anon1 { int n; - struct { // { dg-warning "invalid use \[^\n\r\]* with a zero-size array" } + struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct|invalid use \[^\n\r\]* with a zero-size array" } int good[0]; // { dg-warning "forbids zero-size array" } - }; // { dg-warning "anonymous struct" } + }; }; ASSERT_AT_END (Anon1, good); struct Anon2 { - struct { // { dg-warning "invalid use" } + struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct|invalid use" } int n; - struct { + struct { // { dg-warning "12:ISO C\\+\\+ prohibits anonymous struct" } int good[0]; // { dg-warning "zero-size array" } - }; // { dg-warning "anonymous struct" } - }; // { dg-warning "anonymous struct" } + }; + }; }; ASSERT_AT_END (Anon2, good); struct Anon3 { - struct { // { dg-warning "invalid use" } - struct { + struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct|invalid use" } + struct { // { dg-warning "12:ISO C\\+\\+ prohibits anonymous struct" } int n; int good[0]; // { dg-warning "zero-size array" } - }; // { dg-warning "anonymous struct" } - }; // { dg-warning "anonymous struct" } + }; + }; }; ASSERT_AT_END (Anon3, good); struct Anon4 { - struct { + struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct" } int in_empty_struct[0]; // { dg-warning "zero-size array|in an otherwise empty" } - }; // { dg-warning "anonymous struct" } + }; }; struct Anon5 { - struct { + struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct" } int not_at_end[0]; // { dg-warning "zero-size array|not at end" } - }; // { dg-warning "anonymous struct" } + }; int n; }; struct Anon6 { - struct { - struct { + struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct" } + struct { // { dg-warning "12:ISO C\\+\\+ prohibits anonymous struct" } int not_at_end[0]; // { dg-warning "zero-size array|not at end" } - }; // { dg-warning "anonymous struct" } + }; int n; - }; // { dg-warning "anonymous struct" } + }; }; struct Anon7 { - struct { - struct { + struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct" } + struct { // { dg-warning "12:ISO C\\+\\+ prohibits anonymous struct" } int not_at_end[0]; // { dg-warning "zero-size array|not at end" } - }; // { dg-warning "anonymous struct" } - }; // { dg-warning "anonymous struct" } + }; + }; int n; }; Index: testsuite/g++.dg/template/error17.C =================================================================== --- testsuite/g++.dg/template/error17.C (revision 276845) +++ testsuite/g++.dg/template/error17.C (working copy) @@ -4,6 +4,6 @@ template void foo() { - union { struct { }; }; // { dg-error "prohibits anonymous struct" "anon" } + union { struct { }; }; // { dg-error "18:ISO C\\+\\+ prohibits anonymous struct" } // { dg-error "18:anonymous struct not inside" "not inside" { target *-*-* } .-1 } }