From patchwork Tue Aug 24 13:56:08 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rodrigo Rivas X-Patchwork-Id: 62593 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 9604FB70B4 for ; Tue, 24 Aug 2010 23:56:22 +1000 (EST) Received: (qmail 19185 invoked by alias); 24 Aug 2010 13:56:21 -0000 Received: (qmail 19173 invoked by uid 22791); 24 Aug 2010 13:56:19 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mail-ew0-f47.google.com (HELO mail-ew0-f47.google.com) (209.85.215.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 24 Aug 2010 13:56:11 +0000 Received: by ewy7 with SMTP id 7so3611042ewy.20 for ; Tue, 24 Aug 2010 06:56:08 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.186.207 with SMTP id w57mr825325wem.19.1282658168194; Tue, 24 Aug 2010 06:56:08 -0700 (PDT) Received: by 10.216.53.137 with HTTP; Tue, 24 Aug 2010 06:56:08 -0700 (PDT) In-Reply-To: <4C735352.3020804@redhat.com> References: <1280185724.5689.2.camel@abajo> <4C6C5BD8.30606@redhat.com> <4C735352.3020804@redhat.com> Date: Tue, 24 Aug 2010 15:56:08 +0200 Message-ID: Subject: Re: [PATCH, C++] PR43824 pedantic with inline namespaces From: Rodrigo Rivas To: Jason Merrill Cc: gcc-patches@gcc.gnu.org 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 > That looks OK, but it needs a ChangeLog entry.  And I'm surprised that the > testsuite didn't need any changes as a result; did you run make check-c++? Ops! Indeed. As commented in PR43824 I've defined this warning as a -pedantic only warning (OPT_pedantic). That is different from the other maybe_warn_cxx0x warnings. That's needed because there are a few testcases (g++.dg/lookup/strong-using-?.C) that use inline namespaces outside the cpp0x directory. Also, I've given a try to the changelog below. Regards. Rodrigo. --- gcc/cp 2010-08-24 Rodrigo Rivas PR c++/43824 * error.c (maybe_warn_cpp0x): Add new warning CPP0X_INLINE_NAMESPACES. * parser.c (cp_parser_namespace_definition): Likewise. * cp-tree.h (cpp0x_warn_str): Likewise. gcc/testsuite/ 2010-08-24 Rodrigo Rivas PR c++/43824 * g++.dg/lookup/strong-using-1.C: Set dg-options to "" to avoid the -pedantic errors. * g++.dg/lookup/strong-using-2.C: Likewise. * g++.dg/lookup/strong-using-3.C: Likewise. * g++.dg/lookup/strong-using-5.C: Likewise. * g++.dg/cpp0x/inline-ns3.C: Add -std=c++0x. * g++.dg/cpp0x/inline-ns4.C: New. * g++.dg/cpp0x/inline-ns5.C: New. Index: gcc/testsuite/g++.dg/lookup/strong-using-1.C =================================================================== --- gcc/testsuite/g++.dg/lookup/strong-using-1.C (revision 163449) +++ gcc/testsuite/g++.dg/lookup/strong-using-1.C (working copy) @@ -1,5 +1,6 @@ // PR c++/13594 (secondary) +// { dg-options "" } // { dg-do compile } namespace fool { Index: gcc/testsuite/g++.dg/lookup/strong-using-5.C =================================================================== --- gcc/testsuite/g++.dg/lookup/strong-using-5.C (revision 163449) +++ gcc/testsuite/g++.dg/lookup/strong-using-5.C (working copy) @@ -1,5 +1,7 @@ // PR c++/33486 +// { dg-options "" } + namespace A { inline namespace B Index: gcc/testsuite/g++.dg/lookup/strong-using-2.C =================================================================== --- gcc/testsuite/g++.dg/lookup/strong-using-2.C (revision 163449) +++ gcc/testsuite/g++.dg/lookup/strong-using-2.C (working copy) @@ -1,5 +1,6 @@ // PR c++/13594 +// { dg-options "" } // { dg-do compile } namespace foo { Index: gcc/testsuite/g++.dg/lookup/strong-using-3.C =================================================================== --- gcc/testsuite/g++.dg/lookup/strong-using-3.C (revision 163449) +++ gcc/testsuite/g++.dg/lookup/strong-using-3.C (working copy) @@ -1,5 +1,6 @@ // PR c++/13659 +// { dg-options "" } // { dg-do compile } namespace bar { Index: gcc/testsuite/g++.dg/cpp0x/inline-ns3.C =================================================================== --- gcc/testsuite/g++.dg/cpp0x/inline-ns3.C (revision 163449) +++ gcc/testsuite/g++.dg/cpp0x/inline-ns3.C (working copy) @@ -1,3 +1,5 @@ +// { dg-options -std=c++0x } + namespace C { void f(); Index: gcc/testsuite/g++.dg/cpp0x/inline-ns4.C =================================================================== --- gcc/testsuite/g++.dg/cpp0x/inline-ns4.C (revision 0) +++ gcc/testsuite/g++.dg/cpp0x/inline-ns4.C (revision 0) @@ -0,0 +1,2 @@ +// { dg-options "-std=gnu++98 -pedantic" } +inline namespace { } // { dg-warning "inline namespaces" } Index: gcc/testsuite/g++.dg/cpp0x/inline-ns5.C =================================================================== --- gcc/testsuite/g++.dg/cpp0x/inline-ns5.C (revision 0) +++ gcc/testsuite/g++.dg/cpp0x/inline-ns5.C (revision 0) @@ -0,0 +1,2 @@ +// { dg-options "-std=gnu++98 -pedantic-errors" } +inline namespace { } // { dg-error "inline namespaces" } Index: gcc/cp/error.c =================================================================== --- gcc/cp/error.c (revision 163449) +++ gcc/cp/error.c (working copy) @@ -3029,6 +3029,11 @@ maybe_warn_cpp0x (cpp0x_warn_str str) "defaulted and deleted functions " "only available with -std=c++0x or -std=gnu++0x"); break; + case CPP0X_INLINE_NAMESPACES: + pedwarn (input_location, OPT_pedantic, + "inline namespaces " + "only available with -std=c++0x or -std=gnu++0x"); + break; default: gcc_unreachable(); } Index: gcc/cp/parser.c =================================================================== --- gcc/cp/parser.c (revision 163449) +++ gcc/cp/parser.c (working copy) @@ -13246,6 +13467,7 @@ cp_parser_namespace_definition (cp_parser* parser) if (cp_lexer_next_token_is_keyword (parser->lexer, RID_INLINE)) { + maybe_warn_cpp0x (CPP0X_INLINE_NAMESPACES); is_inline = true; cp_lexer_consume_token (parser->lexer); } Index: gcc/cp/cp-tree.h =================================================================== --- gcc/cp/cp-tree.h (revision 163449) +++ gcc/cp/cp-tree.h (working copy) @@ -387,7 +387,9 @@ typedef enum cpp0x_warn_str /* scoped enums */ CPP0X_SCOPED_ENUMS, /* defaulted and deleted functions */ - CPP0X_DEFAULTED_DELETED + CPP0X_DEFAULTED_DELETED, + /* inline namespaces */ + CPP0X_INLINE_NAMESPACES } cpp0x_warn_str; /* The various kinds of operation used by composite_pointer_type. */