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]: Fix 9212


Mark,
this fixes 9212, a parsing error. Although this is an obvious fix, it
is not 'orthogonally-clean', in that CP_PARSER_DECLARATOR_EITHER also
means 'need unqualified-id'. A theoretically cleaner patch would have
to pass something else down.

built & tested on i686-pc-linux-gnu, ok?

nathan
--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
         The voices in my head said this was stupid too
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org

2003-01-07  Nathan Sidwell  <nathan@codesourcery.com>

	PR C++/9212
	* parser.c (cp_parser_direct_declarator): If accepting either
	abstract or named, the name must be an unqualified-id.

Index: cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.20
diff -c -3 -p -r1.20 parser.c
*** cp/parser.c	6 Jan 2003 18:40:18 -0000	1.20
--- cp/parser.c	7 Jan 2003 13:49:16 -0000
*************** typedef enum cp_parser_declarator_kind
*** 1132,1138 ****
    CP_PARSER_DECLARATOR_ABSTRACT,
    /* We want a named declarator.  */
    CP_PARSER_DECLARATOR_NAMED,
!   /* We don't mind.  */
    CP_PARSER_DECLARATOR_EITHER
  } cp_parser_declarator_kind;
  
--- 1132,1138 ----
    CP_PARSER_DECLARATOR_ABSTRACT,
    /* We want a named declarator.  */
    CP_PARSER_DECLARATOR_NAMED,
!   /* We don't mind, but the name must be an unqualified-id  */
    CP_PARSER_DECLARATOR_EITHER
  } cp_parser_declarator_kind;
  
*************** cp_parser_direct_declarator (parser, dcl
*** 10302,10317 ****
  	  if (dcl_kind == CP_PARSER_DECLARATOR_EITHER)
  	    cp_parser_parse_tentatively (parser);
  	  declarator = cp_parser_declarator_id (parser);
! 	  if (dcl_kind == CP_PARSER_DECLARATOR_EITHER
! 	      && !cp_parser_parse_definitely (parser))
! 	    declarator = error_mark_node;
  	  if (declarator == error_mark_node)
  	    break;
  	  
  	  if (TREE_CODE (declarator) == SCOPE_REF)
  	    {
  	      tree scope = TREE_OPERAND (declarator, 0);
! 	  
  	      /* In the declaration of a member of a template class
  	     	 outside of the class itself, the SCOPE will sometimes
  	     	 be a TYPENAME_TYPE.  For example, given:
--- 10302,10325 ----
  	  if (dcl_kind == CP_PARSER_DECLARATOR_EITHER)
  	    cp_parser_parse_tentatively (parser);
  	  declarator = cp_parser_declarator_id (parser);
! 	  if (dcl_kind == CP_PARSER_DECLARATOR_EITHER)
! 	    {
! 	      if (!cp_parser_parse_definitely (parser))
! 		declarator = error_mark_node;
! 	      else if (TREE_CODE (declarator) != IDENTIFIER_NODE)
! 		{
! 		  cp_parser_error (parser, "expected unqualified-id");
! 		  declarator = error_mark_node;
! 		}
! 	    }
! 	  
  	  if (declarator == error_mark_node)
  	    break;
  	  
  	  if (TREE_CODE (declarator) == SCOPE_REF)
  	    {
  	      tree scope = TREE_OPERAND (declarator, 0);
! 
  	      /* In the declaration of a member of a template class
  	     	 outside of the class itself, the SCOPE will sometimes
  	     	 be a TYPENAME_TYPE.  For example, given:
// { dg-do compile }

// Copyright (C) 2003 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 6 Jan 2003 <nathan@codesourcery.com>

// PR 9212. We erroneously accepted an ill-formed
// function-declaration, rather than a variable initializer.


struct A
{
    enum E { e };
    A(E);
};

struct B
{
    enum F { f };
    B(F);
};

struct C
{
    C(A, B, A);
};

C c(A(A::e), B(B::f), A(A::e)); // This is not a function declaration

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