diff mbox

[C++] PR43824 pedantic with inline namespaces

Message ID AANLkTinxPKd7r6tH4QJzJhvDoK+xy4H0Ev6ry_0BX_5K@mail.gmail.com
State New
Headers show

Commit Message

Rodrigo Rivas Aug. 24, 2010, 1:56 p.m. UTC
> 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 <rodrigorivascosta@gmail.com>

	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 <rodrigorivascosta@gmail.com>

	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.

Comments

Jason Merrill Aug. 25, 2010, 5:26 a.m. UTC | #1
On 08/24/2010 06:56 AM, Rodrigo Rivas wrote:
> 	PR c++/43824
> 	* g++.dg/lookup/strong-using-1.C: Set dg-options to "" to avoid
> 	the -pedantic errors.

"Why" information like "to avoid the -pedantic errors" belongs in 
comments in the code; the ChangeLog entry should only describe the change.

Other than that, this looks ready to go in once your copyright 
assignment is complete.

Jason
diff mbox

Patch

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. */