From patchwork Thu May 24 14:48:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ville Voutilainen X-Patchwork-Id: 919920 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-478400-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="YXjLGAzJ"; 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 40sC2N0Jdvz9s08 for ; Fri, 25 May 2018 00:49:14 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=oTvJrt7dqBEl5ILtOmXC6dEUAJtsLhVuYovaBsSuA0mFKs Owt4FibHN10MCHJUtlcUDOMJmj6uJukomkzxLPIaqQWo1agl+cL1xU9zyxwXEp+b V+Ja3U8D6ZClN1B3hmh/NfJhso1FkCws5CzkD3jpmV/HeDTLtOP0xnGnwVjMo= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=sc0au6xD3JR8IazrZXjOXJaMlpA=; b=YXjLGAzJZrNIcEy2Y2Dp PN1Ug3lilbY44hnU/Jh/7f+9+7C1Mf41yl0nIztVa/6EFWnPBuJNnuxz7CRGHKe7 5dh8Tmym4LmX1MVsfH6q4ESwJfgd9Y4R14xKLkDT/zMo9e2R9J5ORgApCZVNP04Z jOiFW23cJZ9fCtTjDbGGjVM= Received: (qmail 75086 invoked by alias); 24 May 2018 14:49:04 -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 74947 invoked by uid 89); 24 May 2018 14:49:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-oi0-f41.google.com Received: from mail-oi0-f41.google.com (HELO mail-oi0-f41.google.com) (209.85.218.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 24 May 2018 14:49:01 +0000 Received: by mail-oi0-f41.google.com with SMTP id y15-v6so1679278oia.13 for ; Thu, 24 May 2018 07:49:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=AhyzFdZ6EyWMlDg0hJl/U00AOVPwIOkAuzfC2a8oQcQ=; b=Pix387XgZOpGyrdTjhqcG9bXzDs0+K1gqhFuRW78FShhjxkpRp9bIFhMcAPkIx8hv7 rOQHryXt286z07sE3mJRGGBJ6GU/RU13QALl3zyIqa17Paq38gKRx194taPIT4ZzfhTq ZW/lDE5tA3OM/6MOHHYXpl410iP6L9YIzXoKDN7oFm8W/NuDxmObzPivz+TXRAbRJiFi 5U6LFPfuSzr9A8zKRM+DJqpLkrd793HybEAFkbgvZ95CcA7cNrdS22v6Pyd9CVo0UZVw aNqCIqQs1bu/N+Jp7IlMqT68C7e6JqgriwfvuEM72pr3hV5Ul4oxu4CCDS//B62RD3FB B25g== X-Gm-Message-State: ALKqPwdL4tTeXcuA/NH7LuiggSmEOJD9SC+ay/wZvVJyy95dwPrrDuyL Q06qx3CwUuo1BLbU+QoYx25XdWTOQ4ExxbeKkkULLA== X-Google-Smtp-Source: AB8JxZorm1HGwog1eDwqLZyzsitfTfUrm4bablJxmCAMcIser3H4eauzJEOY+2dTYFtfa6yoc5VjwP4rNEylayBwdEI= X-Received: by 2002:aca:eb4c:: with SMTP id j73-v6mr4174178oih.109.1527173339726; Thu, 24 May 2018 07:48:59 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:1715:0:0:0:0:0 with HTTP; Thu, 24 May 2018 07:48:59 -0700 (PDT) From: Ville Voutilainen Date: Thu, 24 May 2018 17:48:59 +0300 Message-ID: Subject: [C++ PATCH] Pedwarn on a non-standard position of a C++ attribute. To: gcc-patches List , Jason Merrill Tested manually on Linux-x64, finishing testing with the full suite on Linux-PPC64. Ok for trunk? 2018-05-24 Ville Voutilainen gcc/cp/ Pedwarn on a non-standard position of a C++ attribute. * parser.c (cp_parser_namespace_definition): Pedwarn about attributes after the namespace name. testsuite/ Pedwarn on a non-standard position of a C++ attribute. * g++.dg/cpp1z/namespace-attribs2.C: New. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 6f51f03..ac68159 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -18588,6 +18588,11 @@ cp_parser_namespace_definition (cp_parser* parser) { identifier = cp_parser_identifier (parser); + if (cp_next_tokens_can_be_std_attribute_p (parser)) + pedwarn (input_location, OPT_Wpedantic, + "standard attributes on namespaces must precede " + "the namespace name"); + /* Parse any attributes specified after the identifier. */ attribs = attr_chainon (attribs, cp_parser_attributes_opt (parser)); } diff --git a/gcc/testsuite/g++.dg/cpp1z/namespace-attribs2.C b/gcc/testsuite/g++.dg/cpp1z/namespace-attribs2.C new file mode 100644 index 0000000..2049da3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/namespace-attribs2.C @@ -0,0 +1,7 @@ +// { dg-options "-std=c++17" } +// { dg-additional-options "-pedantic" } + +namespace B [[deprecated]] {} // { dg-warning "ignored|must precede" } + +namespace [[deprecated]] D {} // { dg-warning "ignored" } +