This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH: PR 26295


This patch fixes PR c++/26295, an ICE on an invalid pointer-to-member
declaration, in which the qualifying name is a namespace.  I moved the
logic to catch this into the parser, and removed it from the
middle-end, following the general policy of finding semantic problems
as soon as possible.

Tested on x86_64-unknown-linux-gnu, applied on the mainline; I will
backport to 4.1 forthwith.

--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713

2006-04-11  Mark Mitchell  <mark@codesourcery.com>

	PR c++/26295
	* decl.c (grokdeclarator): Remove namespace-handling code for
	pointers-to-members.  
	* parser.c (cp_parser_ptr_operator): Check for qualified names
	using namespaces.

2006-04-11  Mark Mitchell  <mark@codesourcery.com>

	PR c++/26295
	* g++.dg/parse/ptrmem4.C: New test.

Index: gcc/cp/parser.c
===================================================================
--- gcc/cp/parser.c	(revision 112844)
+++ gcc/cp/parser.c	(working copy)
@@ -11730,17 +11750,23 @@ cp_parser_ptr_operator (cp_parser* parse
       if (!cp_parser_error_occurred (parser)
 	  && cp_parser_require (parser, CPP_MULT, "`*'"))
 	{
-	  /* The type of which the member is a member is given by the
-	     current SCOPE.  */
-	  *type = parser->scope;
-	  /* The next name will not be qualified.  */
-	  parser->scope = NULL_TREE;
-	  parser->qualifying_scope = NULL_TREE;
-	  parser->object_scope = NULL_TREE;
 	  /* Indicate that the `*' operator was used.  */
 	  code = INDIRECT_REF;
-	  /* Look for the optional cv-qualifier-seq.  */
-	  *cv_quals = cp_parser_cv_qualifier_seq_opt (parser);
+
+	  if (TREE_CODE (parser->scope) == NAMESPACE_DECL)
+	    error ("%qD is a namespace", parser->scope);
+	  else
+	    {
+	      /* The type of which the member is a member is given by the
+		 current SCOPE.  */
+	      *type = parser->scope;
+	      /* The next name will not be qualified.  */
+	      parser->scope = NULL_TREE;
+	      parser->qualifying_scope = NULL_TREE;
+	      parser->object_scope = NULL_TREE;
+	      /* Look for the optional cv-qualifier-seq.  */
+	      *cv_quals = cp_parser_cv_qualifier_seq_opt (parser);
+	    }
 	}
       /* If that didn't work we don't have a ptr-operator.  */
       if (!cp_parser_parse_definitely (parser))
Index: gcc/testsuite/g++.dg/parse/ptrmem4.C
===================================================================
--- gcc/testsuite/g++.dg/parse/ptrmem4.C	(revision 0)
+++ gcc/testsuite/g++.dg/parse/ptrmem4.C	(revision 0)
@@ -0,0 +1,4 @@
+// PR c++/26295
+
+namespace A {}
+int (A::*B)(); // { dg-error "namespace" }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]