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 13975, 13968, 13978


This patch fixes three more relatively minor C++ regressions.

PR 13975 was a crash when the improved diagnostic-printing routines in
the new C++ parser tried to print out access-specifier keywords.  The
value of all keywords should be a IDENTIFIER_NODE, but here it was
not.

PR 13968 and PR 13978 are fallout from the uses_template_parms
speedups.  That will teach me to try to do major performance
improvements on the release branch.

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

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

2004-02-03  Mark Mitchell  <mark@codesourcery.com>

	PR c++/13975
	* tree.h (enum tree_index): Add TI_PUBLIC, TI_PROTECTED, and
	TI_PRIVATE.
	(access_public_node): Redefine.
	(access_protected_node): Likewise.
	(access_private_node): Likewise.
	* tree.c (build_common_tree_nodes): Create access_public_node,
	access_protected_node, and access_private_node.

2004-02-03  Mark Mitchell  <mark@codesourcery.com>

	PR c++/13978
	* pt.c (build_non_dependent_expr): Do not build
	NON_DEPENDENT_EXPRs for FUNCTION_DECLs or TEMPLATE_DECLs.

	PR c++/13968
	* semantics.c (finish_id_expression): Do not return an
	IDENTIFIER_NODE when lookup finds a VAR_DECL.

	PR c++/13975
	* parser.c (cp_parser_simple_declaration): When skipping to the
	end of the statement swallow the terminating semicolon.

2004-02-03  Mark Mitchell  <mark@codesourcery.com>

	PR c++/13978
	* g++.dg/template/koenig4.C: New test.

	PR c++/13968
	* g++.dg/template/crash17.C: New test.

	PR c++/13975
	* g++.dg/parse/error13.C: New test.
	* g++.old-deja/g++.robertl/eb125.C: Tweak error messages.

Index: tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.c,v
retrieving revision 1.342.2.1
diff -c -5 -p -r1.342.2.1 tree.c
*** tree.c	29 Jan 2004 18:24:42 -0000	1.342.2.1
--- tree.c	3 Feb 2004 16:08:15 -0000
*************** build_common_tree_nodes (int signed_char
*** 4868,4877 ****
--- 4868,4881 ----
    unsigned_intQI_type_node = make_unsigned_type (GET_MODE_BITSIZE (QImode));
    unsigned_intHI_type_node = make_unsigned_type (GET_MODE_BITSIZE (HImode));
    unsigned_intSI_type_node = make_unsigned_type (GET_MODE_BITSIZE (SImode));
    unsigned_intDI_type_node = make_unsigned_type (GET_MODE_BITSIZE (DImode));
    unsigned_intTI_type_node = make_unsigned_type (GET_MODE_BITSIZE (TImode));
+   
+   access_public_node = get_identifier ("public");
+   access_protected_node = get_identifier ("protected");
+   access_private_node = get_identifier ("private");
  }
  
  /* Call this function after calling build_common_tree_nodes and set_sizetype.
     It will create several other common tree nodes.  */
  
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.458
diff -c -5 -p -r1.458 tree.h
*** tree.h	16 Jan 2004 07:20:29 -0000	1.458
--- tree.h	3 Feb 2004 16:08:16 -0000
*************** enum tree_index
*** 1814,1823 ****
--- 1814,1827 ----
  
    TI_BITSIZE_ZERO,
    TI_BITSIZE_ONE,
    TI_BITSIZE_UNIT,
  
+   TI_PUBLIC,
+   TI_PROTECTED,
+   TI_PRIVATE,
+ 
    TI_BOOLEAN_FALSE,
    TI_BOOLEAN_TRUE,
  
    TI_COMPLEX_INTEGER_TYPE,
    TI_COMPLEX_FLOAT_TYPE,
*************** extern GTY(()) tree global_trees[TI_MAX]
*** 1899,1911 ****
  #define bitsize_zero_node		global_trees[TI_BITSIZE_ZERO]
  #define bitsize_one_node		global_trees[TI_BITSIZE_ONE]
  #define bitsize_unit_node		global_trees[TI_BITSIZE_UNIT]
  
  /* Base access nodes.  */
! #define access_public_node		NULL_TREE
! #define access_protected_node		size_zero_node
! #define access_private_node		size_one_node
  
  #define null_pointer_node		global_trees[TI_NULL_POINTER]
  
  #define float_type_node			global_trees[TI_FLOAT_TYPE]
  #define double_type_node		global_trees[TI_DOUBLE_TYPE]
--- 1903,1915 ----
  #define bitsize_zero_node		global_trees[TI_BITSIZE_ZERO]
  #define bitsize_one_node		global_trees[TI_BITSIZE_ONE]
  #define bitsize_unit_node		global_trees[TI_BITSIZE_UNIT]
  
  /* Base access nodes.  */
! #define access_public_node		global_trees[TI_PUBLIC]
! #define access_protected_node	        global_trees[TI_PROTECTED]
! #define access_private_node		global_trees[TI_PRIVATE]
  
  #define null_pointer_node		global_trees[TI_NULL_POINTER]
  
  #define float_type_node			global_trees[TI_FLOAT_TYPE]
  #define double_type_node		global_trees[TI_DOUBLE_TYPE]
Index: cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.157.2.7
diff -c -5 -p -r1.157.2.7 parser.c
*** cp/parser.c	2 Feb 2004 10:15:19 -0000	1.157.2.7
--- cp/parser.c	3 Feb 2004 16:08:18 -0000
*************** cp_parser_simple_declaration (cp_parser*
*** 6504,6513 ****
--- 6504,6516 ----
        else
  	{
  	  cp_parser_error (parser, "expected `,' or `;'");
  	  /* Skip tokens until we reach the end of the statement.  */
  	  cp_parser_skip_to_end_of_statement (parser);
+ 	  /* If the next token is now a `;', consume it.  */
+ 	  if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON))
+ 	    cp_lexer_consume_token (parser->lexer);
  	  goto done;
  	}
        /* After the first time around, a function-definition is not
  	 allowed -- even if it was OK at first.  For example:
  
Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.816.2.7
diff -c -5 -p -r1.816.2.7 pt.c
*** cp/pt.c	2 Feb 2004 16:26:44 -0000	1.816.2.7
--- cp/pt.c	3 Feb 2004 16:08:19 -0000
*************** build_non_dependent_expr (tree expr)
*** 12025,12035 ****
       "p == 0" where "p" is a pointer can be determined.  */
    if (null_ptr_cst_p (expr))
      return expr;
    /* Preserve OVERLOADs; the functions must be available to resolve
       types.  */
!   if (TREE_CODE (expr) == OVERLOAD)
      return expr;
    /* Preserve string constants; conversions from string constants to
       "char *" are allowed, even though normally a "const char *"
       cannot be used to initialize a "char *".  */
    if (TREE_CODE (expr) == STRING_CST)
--- 12025,12037 ----
       "p == 0" where "p" is a pointer can be determined.  */
    if (null_ptr_cst_p (expr))
      return expr;
    /* Preserve OVERLOADs; the functions must be available to resolve
       types.  */
!   if (TREE_CODE (expr) == OVERLOAD 
!       || TREE_CODE (expr) == FUNCTION_DECL
!       || TREE_CODE (expr) == TEMPLATE_DECL)
      return expr;
    /* Preserve string constants; conversions from string constants to
       "char *" are allowed, even though normally a "const char *"
       cannot be used to initialize a "char *".  */
    if (TREE_CODE (expr) == STRING_CST)
Index: cp/semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/semantics.c,v
retrieving revision 1.381.4.5
diff -c -5 -p -r1.381.4.5 semantics.c
*** cp/semantics.c	1 Feb 2004 13:01:15 -0000	1.381.4.5
--- cp/semantics.c	3 Feb 2004 16:08:19 -0000
*************** finish_id_expression (tree id_expression
*** 2522,2531 ****
--- 2522,2536 ----
  	     constant -- yet.  No error is issued because it might be
  	     constant when things are instantiated.  */
  	  if (integral_constant_expression_p)
  	    *non_integral_constant_expression_p = true;
  	  *idk = CP_ID_KIND_UNQUALIFIED_DEPENDENT;
+ 	  /* If we found a variable, then name lookup during the
+ 	     instantiation will always resolve to the same VAR_DECL
+ 	     (or an instantiation thereof).  */
+ 	  if (TREE_CODE (decl) == VAR_DECL)
+ 	    return decl;
  	  return id_expression;
  	}
  
        /* Only certain kinds of names are allowed in constant
         expression.  Enumerators and template parameters 
Index: testsuite/g++.dg/parse/error13.C
===================================================================
RCS file: testsuite/g++.dg/parse/error13.C
diff -N testsuite/g++.dg/parse/error13.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/parse/error13.C	3 Feb 2004 16:08:21 -0000
***************
*** 0 ****
--- 1,13 ----
+ // PR c++/13975
+ 
+ public: // { dg-error "" }
+ 
+ int i;
+ 
+ protected: // { dg-error "" }
+ 
+ int j;
+ 
+ private: // { dg-error "" }
+ 
+ int k;
Index: testsuite/g++.dg/template/crash17.C
===================================================================
RCS file: testsuite/g++.dg/template/crash17.C
diff -N testsuite/g++.dg/template/crash17.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/template/crash17.C	3 Feb 2004 16:08:21 -0000
***************
*** 0 ****
--- 1,19 ----
+ template <int I> 
+ struct A {
+ };
+ 
+ template <typename T>
+ struct B {
+   typedef typename T::type type;
+   static const type j = T::j;
+ 
+   A<j> b;
+ };
+ 
+ struct C {
+   typedef int type;
+   static const int j = 3;
+ };
+ 
+ int i = B<C>::j;
+ 
Index: testsuite/g++.dg/template/koenig4.C
===================================================================
RCS file: testsuite/g++.dg/template/koenig4.C
diff -N testsuite/g++.dg/template/koenig4.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/template/koenig4.C	3 Feb 2004 16:08:21 -0000
***************
*** 0 ****
--- 1,12 ----
+ // PR c++/13978
+ 
+ namespace ns {
+   template <class TP> void func1(TP* t);
+   struct A {};
+ }
+  
+ template < class TP >
+ void func2() {
+   func1( new ns::A() );
+ }
+ 
Index: testsuite/g++.old-deja/g++.robertl/eb125.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.old-deja/g++.robertl/eb125.C,v
retrieving revision 1.6
diff -c -5 -p -r1.6 eb125.C
*** testsuite/g++.old-deja/g++.robertl/eb125.C	1 May 2003 02:02:58 -0000	1.6
--- testsuite/g++.old-deja/g++.robertl/eb125.C	3 Feb 2004 16:08:21 -0000
*************** class test_square
*** 15,22 ****
  
  
  template <class BOX> void test(BOX *the_box)  // { dg-error "" } semicolon missing
      {x
      the_box->print();
!     }; // { dg-error "" }
  
  template void test<> (test_box *); // { dg-error "" }
--- 15,22 ----
  
  
  template <class BOX> void test(BOX *the_box)  // { dg-error "" } semicolon missing
      {x
      the_box->print();
!     };
  
  template void test<> (test_box *); // { dg-error "" }


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