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 15044, 15317, 15329


Three more simple C++ regressions.

Tested on i686-pc-linux-gnu, applied on the mainline and on the
branch.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2004-05-23  Mark Mitchell  <mark@codesourcery.com>

	PR c++/15044
	* parser.c (cp_parser_class_head): Robustify.

	PR c++/15317
	* parser.c (cp_parser_decl_specifier_seq): Correct error in
	comment.
	(cp_parser_constructor_declarator_p): Treat attributes
	as decl-specifiers.

	PR c++/15329
	* typeck.c (build_unary_op): Do not attempt to resolve casts to
	base classes in templates.

2004-05-23  Mark Mitchell  <mark@codesourcery.com>

	PR c++/15044
	* g++.dg/template/error12.C: New test.

	PR c++/15317
	* g++.dg/ext/attrib15.C: New test.

	PR c++/15329
	* g++.dg/template/ptrmem9.C: New test.

Index: cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.157.2.27
diff -c -5 -p -r1.157.2.27 parser.c
*** cp/parser.c	23 May 2004 17:52:16 -0000	1.157.2.27
--- cp/parser.c	23 May 2004 23:35:27 -0000
*************** cp_parser_simple_declaration (cp_parser*
*** 6568,6579 ****
       friend
       typedef  
  
     GNU Extension:
  
!    decl-specifier-seq:
!      decl-specifier-seq [opt] attributes
  
     Returns a TREE_LIST, giving the decl-specifiers in the order they
     appear in the source code.  The TREE_VALUE of each node is the
     decl-specifier.  For a keyword (such as `auto' or `friend'), the
     TREE_VALUE is simply the corresponding TREE_IDENTIFIER.  For the
--- 6568,6579 ----
       friend
       typedef  
  
     GNU Extension:
  
!    decl-specifier:
!      attributes
  
     Returns a TREE_LIST, giving the decl-specifiers in the order they
     appear in the source code.  The TREE_VALUE of each node is the
     decl-specifier.  For a keyword (such as `auto' or `friend'), the
     TREE_VALUE is simply the corresponding TREE_IDENTIFIER.  For the
*************** cp_parser_class_head (cp_parser* parser,
*** 12012,12022 ****
  	}
      }
  
    pop_deferring_access_checks ();
  
!   cp_parser_check_for_invalid_template_id (parser, id);
  
    /* If it's not a `:' or a `{' then we can't really be looking at a
       class-head, since a class-head only appears as part of a
       class-specifier.  We have to detect this situation before calling
       xref_tag, since that has irreversible side-effects.  */
--- 12012,12023 ----
  	}
      }
  
    pop_deferring_access_checks ();
  
!   if (id)
!     cp_parser_check_for_invalid_template_id (parser, id);
  
    /* If it's not a `:' or a `{' then we can't really be looking at a
       class-head, since a class-head only appears as part of a
       class-specifier.  We have to detect this situation before calling
       xref_tag, since that has irreversible side-effects.  */
*************** cp_parser_constructor_declarator_p (cp_p
*** 14059,14068 ****
--- 14060,14073 ----
    if (constructor_p 
        && cp_parser_require (parser, CPP_OPEN_PAREN, "`('"))
      {
        if (cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_PAREN)
  	  && cp_lexer_next_token_is_not (parser->lexer, CPP_ELLIPSIS)
+ 	  /* A parameter declaration begins with a decl-specifier,
+ 	     which is either the "attribute" keyword, a storage class
+ 	     specifier, or (usually) a type-specifier.  */
+ 	  && !cp_lexer_next_token_is_keyword (parser->lexer, RID_ATTRIBUTE)
  	  && !cp_parser_storage_class_specifier_opt (parser))
  	{
  	  tree type;
  	  bool pop_p = false;
  	  unsigned saved_num_template_parameter_lists;
Index: cp/typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/typeck.c,v
retrieving revision 1.519.2.15
diff -c -5 -p -r1.519.2.15 typeck.c
*** cp/typeck.c	22 May 2004 19:16:48 -0000	1.519.2.15
--- cp/typeck.c	23 May 2004 23:35:28 -0000
*************** build_unary_op (enum tree_code code, tre
*** 4061,4071 ****
  	argtype = build_pointer_type (argtype);
  
        {
  	tree addr;
  
! 	if (TREE_CODE (arg) != COMPONENT_REF)
  	  addr = build_address (arg);
  	else if (TREE_CODE (TREE_OPERAND (arg, 1)) == BASELINK)
  	  {
  	    tree fn = BASELINK_FUNCTIONS (TREE_OPERAND (arg, 1));
  
--- 4061,4075 ----
  	argtype = build_pointer_type (argtype);
  
        {
  	tree addr;
  
! 	if (TREE_CODE (arg) != COMPONENT_REF
! 	    /* Inside a template, we are processing a non-dependent
! 	       expression so we can just form an ADDR_EXPR with the
! 	       correct type.  */
! 	    || processing_template_decl)
  	  addr = build_address (arg);
  	else if (TREE_CODE (TREE_OPERAND (arg, 1)) == BASELINK)
  	  {
  	    tree fn = BASELINK_FUNCTIONS (TREE_OPERAND (arg, 1));
  
Index: testsuite/g++.dg/ext/attrib15.C
===================================================================
RCS file: testsuite/g++.dg/ext/attrib15.C
diff -N testsuite/g++.dg/ext/attrib15.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/ext/attrib15.C	23 May 2004 23:35:28 -0000
***************
*** 0 ****
--- 1,9 ----
+ // PR c++/15317
+ 
+ struct A
+ {
+   A(char);
+ };
+ A::A(__attribute__((unused)) char i2)
+ {}
+ 
Index: testsuite/g++.dg/template/error12.C
===================================================================
RCS file: testsuite/g++.dg/template/error12.C
diff -N testsuite/g++.dg/template/error12.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/template/error12.C	23 May 2004 23:35:28 -0000
***************
*** 0 ****
--- 1,4 ----
+ // PR c++/15044
+ 
+ template class <num_t> class a { num_t n; } // { dg-error "" }
+ 
Index: testsuite/g++.dg/template/ptrmem9.C
===================================================================
RCS file: testsuite/g++.dg/template/ptrmem9.C
diff -N testsuite/g++.dg/template/ptrmem9.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/template/ptrmem9.C	23 May 2004 23:35:28 -0000
***************
*** 0 ****
--- 1,9 ----
+ // PR c++/15329
+ 
+ struct S {}; 
+  
+ template <typename> struct X { 
+     S s; 
+     void foo (void (S::*p)()) 
+       { (s.*p)(); } 
+ }; 


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