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: Remove IDENTIFIER_IMPLICIT_DECL and IDENTIFIER_ERROR_LOCUS


After the discussion yesterday about DECL_ASSEMBLER_NAME, I looked at
some of the places that G++ was still using DECL_ASSEMBLER_NAME.  That
lead me to look at our lang_identifier struct, which is really an
embarassment: several of the fields are used by almost no identifiers.

In particular, implicit_decl was not used *at all*.  The error_locus
field was only used for identifiers where there was some problem with
the declaration in question, and, even then, inconsistently.  The
label_value slot is only used for labels, of which the average
translation unit has very few.  And IDENTIFIER_TEMPLATE is only used
for class templates.

And yet, we use all those slots, for every identifier.

This patch kills IDENTIFIER_ERROR_LOCUS and IDENTIFIER_IMPLICIT_DECL.

I didn't get to IDENTIFIER_LABEL_VALUE or IDENTIFIER_TEMPLATE,
although those should clearly go as well.

The other embarassment here is that DECL_ASSEMBLER_NAME is an
IDENTIFIER_NODE.  It should just be a "char *".  There is no need for
TREE_TYPE, TREE_CHAIN, or IDENTIFIER_CLASS_VALUE for a mangled name.
We're wasting roughly 25 to 50 bytes per mangled name as a result,
depending on whether you're on a 32-bit or 64-bit architecture.

Anyhow, this is a start.

The testsuite changes come because I made one of our error messages
more uniform: some messages talked about "undeclared" things and some
about things that were "not declared".  I made the messages in
unqualified_name_lookup_error a bit more consistent, which required
tweaking some of the test error messages.

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

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

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

	* class.c (check_methods): Don't use IDENTIFIER_ERROR_LOCUS.
	* cp-tree.h (DECL_INVALID_OVERRIDER_P): New macro.
	(lang_identifier): Remove implicit_decl and error_locus.
	(IDENTIFIER_IMPLICIT_DECL): Remove.
	(SET_IDENTIFIER_IMPLICTI_DECL): Likewise.
	(IDENTIFIER_ERROR_LOCUS): Likewise.
	(SET_IDENTIFIER_ERROR_LOCUS): Likewise.
	(TYPE_ASSEMBLER_NAME_STRING): Likewise.
	(TYPE_ASSEMBLER_NAME_LENGTH): Likewise.
	(implicitly_declare): Remove.
	* decl.c (warn_extern_redeclared_static): Remove check of
	IDENTIFIER_IMPLICIT_DECL.
	(duplicate_decls): Don't check IDENTIFIER_ERROR_LOCUS.
	(implicitly_declare): Remove.
	(grok_ctor_properties): Don't set IDENTIFIER_ERROR_LOCUS.
	(start_function): Don't check IDENTIFIER_IMPLICIT_DECL.
	(start_method): Don't check IDENTIFIER_ERROR_LOCUS.
	* lex.c (unqualified_name_lookup_error): Create a dummy VAR_DECL
	in the innermost scope, rather than at namespace scope.
	* name-lookup.c (push_local_binding): Give it external linkage.
	(pushdecl): Remove dead code.
	* name-lookup.h (push_local_binding): Declare it.
	* ptree.c (cxx_print_identifier): Don't print
	IDENTIFIER_IMPLICIT_DECL or IDENTIFIER_ERROR_LOCUS.
	* search.c (check_final_overrider): Use DECL_INVALID_OVERRIDER_P,
	not IDENTIFIER_ERROR_LOCUS.
	* typeck.c (build_function_call): Remove dead code.

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

	* g++.dg/lookup/koenig1.C: Tweak error messages.
	* g++.dg/lookup/used-before-declaration.C: Likewise.
	* g++.dg/other/do1.C: Likewise.
	* g++.dg/overload/koenig1.C: Likewise.
	* g++.dg/parse/crash13.C: Likewise.
	* g++.dg/template/instantiate3.C: Likewise.
	
Index: cp/class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/class.c,v
retrieving revision 1.602
diff -c -5 -p -r1.602 class.c
*** cp/class.c	29 Feb 2004 23:10:41 -0000	1.602
--- cp/class.c	3 Mar 2004 02:12:20 -0000
*************** check_methods (tree t)
*** 3681,3695 ****
  {
    tree x;
  
    for (x = TYPE_METHODS (t); x; x = TREE_CHAIN (x))
      {
-       /* If this was an evil function, don't keep it in class.  */
-       if (DECL_ASSEMBLER_NAME_SET_P (x) 
- 	  && IDENTIFIER_ERROR_LOCUS (DECL_ASSEMBLER_NAME (x)))
- 	continue;
- 
        check_for_override (x, t);
        if (DECL_PURE_VIRTUAL_P (x) && ! DECL_VINDEX (x))
  	cp_error_at ("initializer specified for non-virtual method `%D'", x);
  
        /* The name of the field is the original field name
--- 3681,3690 ----
Index: cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.954
diff -c -5 -p -r1.954 cp-tree.h
*** cp/cp-tree.h	17 Feb 2004 18:32:41 -0000	1.954
--- cp/cp-tree.h	3 Mar 2004 02:12:21 -0000
*************** struct diagnostic_context;
*** 98,107 ****
--- 98,108 ----
        DECL_IMPLICIT_TYPEDEF_P (in a TYPE_DECL)
     3: DECL_IN_AGGR_P.
     4: DECL_C_BIT_FIELD (in a FIELD_DECL)
        DECL_VAR_MARKED_P (in a VAR_DECL)
        DECL_SELF_REFERENCE_P (in a TYPE_DECL)
+       DECL_INVALID_OVERRIRDER_P (in a FUNCTION_DECL)
     5: DECL_INTERFACE_KNOWN.
     6: DECL_THIS_STATIC (in VAR_DECL or FUNCTION_DECL).
     7: DECL_DEAD_FOR_LOCAL (in VAR_DECL).
        DECL_THUNK_P (in a member FUNCTION_DECL)
  
*************** struct lang_identifier GTY(())
*** 222,233 ****
    cxx_binding *namespace_bindings;
    cxx_binding *bindings;
    tree class_value;
    tree class_template_info;
    tree label_value;
-   tree implicit_decl;
-   tree error_locus;
  };
  
  /* In an IDENTIFIER_NODE, nonzero if this identifier is actually a
     keyword.  C_RID_CODE (node) is then the RID_* value of the keyword,
     and C_RID_YYCODE is the token number wanted by Yacc.  */
--- 223,232 ----
*************** typedef enum cp_id_kind
*** 397,416 ****
  #define IDENTIFIER_LABEL_VALUE(NODE) \
    (LANG_IDENTIFIER_CAST (NODE)->label_value)
  #define SET_IDENTIFIER_LABEL_VALUE(NODE, VALUE)   \
    IDENTIFIER_LABEL_VALUE (NODE) = (VALUE)
  
- #define IDENTIFIER_IMPLICIT_DECL(NODE) \
-   (LANG_IDENTIFIER_CAST (NODE)->implicit_decl)
- #define SET_IDENTIFIER_IMPLICIT_DECL(NODE, VALUE) \
-   IDENTIFIER_IMPLICIT_DECL (NODE) = (VALUE)
- 
- #define IDENTIFIER_ERROR_LOCUS(NODE) \
-   (LANG_IDENTIFIER_CAST (NODE)->error_locus)
- #define SET_IDENTIFIER_ERROR_LOCUS(NODE, VALUE)	\
-   IDENTIFIER_ERROR_LOCUS (NODE) = (VALUE)
- 
  /* Nonzero if this identifier is used as a virtual function name somewhere
     (optimizes searches).  */
  #define IDENTIFIER_VIRTUAL_P(NODE) TREE_LANG_FLAG_1 (NODE)
  
  /* Nonzero if this identifier is the prefix for a mangled C++ operator
--- 396,405 ----
*************** enum languages { lang_c, lang_cplusplus,
*** 886,900 ****
  #define TYPE_LINKAGE_IDENTIFIER(NODE) \
    (TYPE_IDENTIFIER (TYPE_MAIN_VARIANT (NODE)))
  #define TYPE_NAME_STRING(NODE) (IDENTIFIER_POINTER (TYPE_IDENTIFIER (NODE)))
  #define TYPE_NAME_LENGTH(NODE) (IDENTIFIER_LENGTH (TYPE_IDENTIFIER (NODE)))
  
- #define TYPE_ASSEMBLER_NAME_STRING(NODE) \
-   (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (TYPE_NAME  (NODE))))
- #define TYPE_ASSEMBLER_NAME_LENGTH(NODE) \
-   (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (TYPE_NAME (NODE))))
- 
  /* Nonzero if NODE has no name for linkage purposes.  */
  #define TYPE_ANONYMOUS_P(NODE) \
    (TAGGED_TYPE_P (NODE) && ANON_AGGRNAME_P (TYPE_LINKAGE_IDENTIFIER (NODE)))
  
  /* The _DECL for this _TYPE.  */
--- 875,884 ----
*************** struct lang_decl GTY(())
*** 1949,1958 ****
--- 1933,1949 ----
  /* Nonzero for FUNCTION_DECL means that this member function
     must be overridden by derived classes.  */
  #define DECL_NEEDS_FINAL_OVERRIDER_P(NODE) \
    (DECL_LANG_SPECIFIC (NODE)->decl_flags.needs_final_overrider)
  
+ /* True (in a FUNCTION_DECL) if NODE is a virtual function that is an
+    invalid overrider for a function from a base class.  Once we have
+    complained about an invalid overrider we avoid complaining about it
+    again.  */
+ #define DECL_INVALID_OVERRIDER_P(NODE) \
+   (DECL_LANG_FLAG_4 (NODE))
+ 
  /* The thunks associated with NODE, a FUNCTION_DECL.  */
  #define DECL_THUNKS(NODE) \
    (DECL_LANG_SPECIFIC (NODE)->u.f.context)
  
  /* Nonzero if NODE is a thunk, rather than an ordinary function.  */
*************** extern void clear_anon_tags			(void);
*** 3612,3622 ****
  extern int decls_match				(tree, tree);
  extern tree duplicate_decls			(tree, tree);
  extern tree pushdecl_top_level			(tree);
  extern tree pushdecl_top_level_and_finish       (tree, tree);
  extern tree push_using_decl                     (tree, tree);
- extern tree implicitly_declare			(tree);
  extern tree declare_local_label                 (tree);
  extern tree define_label			(location_t, tree);
  extern void check_goto				(tree);
  extern void define_case_label			(void);
  extern tree make_typename_type			(tree, tree, tsubst_flags_t);
--- 3603,3612 ----
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1190
diff -c -5 -p -r1.1190 decl.c
*** cp/decl.c	1 Mar 2004 06:23:38 -0000	1.1190
--- cp/decl.c	3 Mar 2004 02:12:21 -0000
*************** decls_match (tree newdecl, tree olddecl)
*** 1095,1109 ****
     the user's control.  */
  
  void
  warn_extern_redeclared_static (tree newdecl, tree olddecl)
  {
-   static const char *const explicit_extern_static_warning
-     = "`%D' was declared `extern' and later `static'";
-   static const char *const implicit_extern_static_warning
-     = "`%D' was declared implicitly `extern' and later `static'";
- 
    tree name;
  
    if (TREE_CODE (newdecl) == TYPE_DECL
        || TREE_CODE (newdecl) == TEMPLATE_DECL
        || TREE_CODE (newdecl) == CONST_DECL
--- 1095,1104 ----
*************** warn_extern_redeclared_static (tree newd
*** 1125,1137 ****
    if (TREE_CODE (olddecl) == FUNCTION_DECL
        && DECL_ARTIFICIAL (olddecl))
      return;
  
    name = DECL_ASSEMBLER_NAME (newdecl);
!   pedwarn (IDENTIFIER_IMPLICIT_DECL (name)
! 	      ? implicit_extern_static_warning
! 	      : explicit_extern_static_warning, newdecl);
    cp_pedwarn_at ("previous declaration of `%D'", olddecl);
  }
  
  /* If NEWDECL is a redeclaration of OLDDECL, merge the declarations.
     If the redeclaration is invalid, a diagnostic is issued, and the
--- 1120,1130 ----
    if (TREE_CODE (olddecl) == FUNCTION_DECL
        && DECL_ARTIFICIAL (olddecl))
      return;
  
    name = DECL_ASSEMBLER_NAME (newdecl);
!   pedwarn ("`%D' was declared `extern' and later `static'", newdecl);
    cp_pedwarn_at ("previous declaration of `%D'", olddecl);
  }
  
  /* If NEWDECL is a redeclaration of OLDDECL, merge the declarations.
     If the redeclaration is invalid, a diagnostic is issued, and the
*************** duplicate_decls (tree newdecl, tree oldd
*** 1371,1384 ****
  	      cp_error_at ("ambiguates old declaration `%#D'", olddecl);
  	    }
  	  else
  	    return NULL_TREE;
  	}
! 
!       /* Already complained about this, so don't do so again.  */
!       else if (current_class_type == NULL_TREE
! 	  || IDENTIFIER_ERROR_LOCUS (DECL_ASSEMBLER_NAME (newdecl)) != current_class_type)
  	{
  	  error ("conflicting declaration '%#D'", newdecl);
  	  cp_error_at ("'%D' has a previous declaration as `%#D'",
                         olddecl, olddecl);
            return NULL_TREE;
--- 1364,1374 ----
  	      cp_error_at ("ambiguates old declaration `%#D'", olddecl);
  	    }
  	  else
  	    return NULL_TREE;
  	}
!       else
  	{
  	  error ("conflicting declaration '%#D'", newdecl);
  	  cp_error_at ("'%D' has a previous declaration as `%#D'",
                         olddecl, olddecl);
            return NULL_TREE;
*************** duplicate_decls (tree newdecl, tree oldd
*** 1941,1983 ****
      make_decl_rtl (olddecl, NULL);
  
    return olddecl;
  }
  
- /* Generate an implicit declaration for identifier FUNCTIONID
-    as a function of type int ().  Print a warning if appropriate.  */
- 
- tree
- implicitly_declare (tree functionid)
- {
-   tree decl;
- 
-   /* We used to reuse an old implicit decl here,
-      but this loses with inline functions because it can clobber
-      the saved decl chains.  */
-   decl = build_lang_decl (FUNCTION_DECL, functionid, default_function_type);
- 
-   DECL_EXTERNAL (decl) = 1;
-   TREE_PUBLIC (decl) = 1;
- 
-   /* ISO standard says implicit declarations are in the innermost block.
-      So we record the decl in the standard fashion.  */
-   pushdecl (decl);
-   rest_of_decl_compilation (decl, NULL, 0, 0);
- 
-   if (warn_implicit
-       /* Only one warning per identifier.  */
-       && IDENTIFIER_IMPLICIT_DECL (functionid) == NULL_TREE)
-     {
-       pedwarn ("implicit declaration of function `%#D'", decl);
-     }
- 
-   SET_IDENTIFIER_IMPLICIT_DECL (functionid, decl);
- 
-   return decl;
- }
- 
  /* Return zero if the declaration NEWDECL is valid
     when the declaration OLDDECL (assumed to be for the same name)
     has already been seen.
     Otherwise return an error message format string with a %s
     where the identifier should go.  */
--- 1931,1940 ----
*************** grok_ctor_properties (tree ctype, tree d
*** 8831,8841 ****
       	 or implicitly defined), there's no need to worry about their
       	 existence.  Theoretically, they should never even be
       	 instantiated, but that's hard to forestall.  */
        error ("invalid constructor; you probably meant `%T (const %T&)'",
  		ctype, ctype);
-       SET_IDENTIFIER_ERROR_LOCUS (DECL_NAME (decl), ctype);
        return 0;
      }
    
    return 1;
  }
--- 8788,8797 ----
*************** start_function (tree declspecs, tree dec
*** 10152,10167 ****
        revert_static_member_fn (decl1);
        last_function_parms = TREE_CHAIN (last_function_parms);
        ctype = NULL_TREE;
      }
  
-   /* Warn if function was previously implicitly declared
-      (but not if we warned then).  */
-   if (! warn_implicit
-       && IDENTIFIER_IMPLICIT_DECL (DECL_NAME (decl1)) != NULL_TREE)
-     cp_warning_at ("`%D' implicitly declared before its definition", IDENTIFIER_IMPLICIT_DECL (DECL_NAME (decl1)));
- 
    /* Set up current_class_type, and enter the scope of the class, if
       appropriate.  */
    if (ctype)
      push_nested_class (ctype);
    else if (DECL_STATIC_FUNCTION_P (decl1))
--- 10108,10117 ----
*************** start_method (tree declspecs, tree decla
*** 10927,10943 ****
    if (fndecl == void_type_node)
      return fndecl;
  
    if (DECL_IN_AGGR_P (fndecl))
      {
!       if (IDENTIFIER_ERROR_LOCUS (DECL_ASSEMBLER_NAME (fndecl)) != current_class_type)
! 	{
! 	  if (DECL_CONTEXT (fndecl)
! 	      && TREE_CODE( DECL_CONTEXT (fndecl)) != NAMESPACE_DECL)
! 	    error ("`%D' is already defined in class `%T'", fndecl,
! 	              DECL_CONTEXT (fndecl));
! 	}
        return void_type_node;
      }
  
    check_template_shadow (fndecl);
  
--- 10877,10890 ----
    if (fndecl == void_type_node)
      return fndecl;
  
    if (DECL_IN_AGGR_P (fndecl))
      {
!       if (DECL_CONTEXT (fndecl)
! 	  && TREE_CODE( DECL_CONTEXT (fndecl)) != NAMESPACE_DECL)
! 	error ("`%D' is already defined in class `%T'", fndecl,
! 	       DECL_CONTEXT (fndecl));
        return void_type_node;
      }
  
    check_template_shadow (fndecl);
  
Index: cp/lex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/lex.c,v
retrieving revision 1.325
diff -c -5 -p -r1.325 lex.c
*** cp/lex.c	1 Mar 2004 20:38:21 -0000	1.325
--- cp/lex.c	3 Mar 2004 02:12:21 -0000
*************** unqualified_name_lookup_error (tree name
*** 625,654 ****
    if (IDENTIFIER_OPNAME_P (name))
      {
        if (name != ansi_opname (ERROR_MARK))
  	error ("`%D' not defined", name);
      }
-   else if (current_function_decl == 0)
-     error ("`%D' was not declared in this scope", name);
    else
      {
!       if (IDENTIFIER_NAMESPACE_VALUE (name) != error_mark_node
! 	  || IDENTIFIER_ERROR_LOCUS (name) != current_function_decl)
  	{
! 	  static int undeclared_variable_notice;
! 
! 	  error ("`%D' undeclared (first use this function)", name);
! 
! 	  if (! undeclared_variable_notice)
! 	    {
! 	      error ("(Each undeclared identifier is reported only once for each function it appears in.)");
! 	      undeclared_variable_notice = 1;
! 	    }
  	}
-       /* Prevent repeated error messages.  */
-       SET_IDENTIFIER_NAMESPACE_VALUE (name, error_mark_node);
-       SET_IDENTIFIER_ERROR_LOCUS (name, current_function_decl);
      }
  
    return error_mark_node;
  }
  
--- 625,646 ----
    if (IDENTIFIER_OPNAME_P (name))
      {
        if (name != ansi_opname (ERROR_MARK))
  	error ("`%D' not defined", name);
      }
    else
      {
!       error ("`%D' was not declared in this scope", name);
!       /* Prevent repeated error messages by creating a VAR_DECL with
! 	 this NAME in the innermost block scope.  */
!       if (current_function_decl)
  	{
! 	  tree decl;
! 	  decl = build_decl (VAR_DECL, name, error_mark_node);
! 	  DECL_CONTEXT (decl) = current_function_decl;
! 	  push_local_binding (name, decl, 0);
  	}
      }
  
    return error_mark_node;
  }
  
Index: cp/name-lookup.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/name-lookup.c,v
retrieving revision 1.42
diff -c -5 -p -r1.42 name-lookup.c
*** cp/name-lookup.c	1 Mar 2004 06:23:38 -0000	1.42
--- cp/name-lookup.c	3 Mar 2004 02:12:22 -0000
*************** Boston, MA 02111-1307, USA.  */
*** 34,44 ****
  
  static cxx_scope *innermost_nonclass_level (void);
  static tree select_decl (cxx_binding *, int);
  static cxx_binding *binding_for_name (cxx_scope *, tree);
  static tree lookup_name_current_level (tree);
- static void push_local_binding (tree, tree, int);
  static tree push_overloaded_decl (tree, int);
  static bool lookup_using_namespace (tree, cxx_binding *, tree,
                                      tree, int);
  static bool qualified_lookup_using_namespace (tree, tree, cxx_binding *, int);
  static tree lookup_type_current_level (tree);
--- 34,43 ----
*************** pushdecl (tree x)
*** 641,657 ****
  	    t = OVL_CURRENT (match);
  	  else
  	    t = NULL_TREE;
  	}
  
!       if (t == error_mark_node)
! 	{
! 	  /* error_mark_node is 0 for a while during initialization!  */
! 	  t = NULL_TREE;
! 	  cp_error_at ("`%#D' used prior to declaration", x);
! 	}
!       else if (t != NULL_TREE)
  	{
  	  if (different_binding_level)
  	    {
  	      if (decls_match (x, t))
  		/* The standard only says that the local extern
--- 640,650 ----
  	    t = OVL_CURRENT (match);
  	  else
  	    t = NULL_TREE;
  	}
  
!       if (t && t != error_mark_node)
  	{
  	  if (different_binding_level)
  	    {
  	      if (decls_match (x, t))
  		/* The standard only says that the local extern
*************** pushdecl (tree x)
*** 824,851 ****
   		  || TREE_CODE (x) == NAMESPACE_DECL
   		  || TREE_CODE (x) == CONST_DECL
   		  || TREE_CODE (x) == TEMPLATE_DECL))
   	    SET_IDENTIFIER_NAMESPACE_VALUE (name, x);
  
- 	  /* Don't forget if the function was used via an implicit decl.  */
- 	  if (IDENTIFIER_IMPLICIT_DECL (name)
- 	      && TREE_USED (IDENTIFIER_IMPLICIT_DECL (name)))
- 	    TREE_USED (x) = 1;
- 
- 	  /* Don't forget if its address was taken in that way.  */
- 	  if (IDENTIFIER_IMPLICIT_DECL (name)
- 	      && TREE_ADDRESSABLE (IDENTIFIER_IMPLICIT_DECL (name)))
- 	    TREE_ADDRESSABLE (x) = 1;
- 
- 	  /* Warn about mismatches against previous implicit decl.  */
- 	  if (IDENTIFIER_IMPLICIT_DECL (name) != NULL_TREE
- 	      /* If this real decl matches the implicit, don't complain.  */
- 	      && ! (TREE_CODE (x) == FUNCTION_DECL
- 		    && TREE_TYPE (TREE_TYPE (x)) == integer_type_node))
- 	    warning
- 	      ("`%D' was previously implicitly declared to return `int'", x);
- 
  	  /* If new decl is `static' and an `extern' was seen previously,
  	     warn about it.  */
  	  if (x != NULL_TREE && t != NULL_TREE && decls_match (x, t))
  	    warn_extern_redeclared_static (x, t);
  	}
--- 817,826 ----
*************** maybe_push_decl (tree decl)
*** 1029,1039 ****
  /* Bind DECL to ID in the current_binding_level, assumed to be a local
     binding level.  If PUSH_USING is set in FLAGS, we know that DECL
     doesn't really belong to this binding level, that it got here
     through a using-declaration.  */
  
! static void
  push_local_binding (tree id, tree decl, int flags)
  {
    struct cp_binding_level *b;
  
    /* Skip over any local classes.  This makes sense if we call
--- 1004,1014 ----
  /* Bind DECL to ID in the current_binding_level, assumed to be a local
     binding level.  If PUSH_USING is set in FLAGS, we know that DECL
     doesn't really belong to this binding level, that it got here
     through a using-declaration.  */
  
! void
  push_local_binding (tree id, tree decl, int flags)
  {
    struct cp_binding_level *b;
  
    /* Skip over any local classes.  This makes sense if we call
Index: cp/name-lookup.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/name-lookup.h,v
retrieving revision 1.18
diff -c -5 -p -r1.18 name-lookup.h
*** cp/name-lookup.h	1 Mar 2004 06:23:38 -0000	1.18
--- cp/name-lookup.h	3 Mar 2004 02:12:22 -0000
*************** extern tree namespace_binding (tree, tre
*** 285,294 ****
--- 285,295 ----
  extern void set_namespace_binding (tree, tree, tree);
  extern tree lookup_namespace_name (tree, tree);
  extern tree lookup_qualified_name (tree, tree, bool, bool);
  extern tree lookup_name_nonclass (tree);
  extern tree lookup_function_nonclass (tree, tree);
+ extern void push_local_binding (tree, tree, int);
  extern int push_class_binding (tree, tree);
  extern bool pushdecl_class_level (tree);
  extern tree pushdecl_namespace_level (tree);
  extern bool push_class_level_binding (tree, tree);
  extern void storetags (tree);
Index: cp/ptree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/ptree.c,v
retrieving revision 1.38
diff -c -5 -p -r1.38 ptree.c
*** cp/ptree.c	9 Dec 2003 04:08:49 -0000	1.38
--- cp/ptree.c	3 Mar 2004 02:12:22 -0000
*************** cxx_print_identifier (FILE *file, tree n
*** 155,166 ****
    print_node (file, "class", IDENTIFIER_CLASS_VALUE (node), indent + 4);
    indent_to (file, indent);
    cxx_print_binding (file, IDENTIFIER_BINDING (node), "local bindings");
    print_node (file, "label", IDENTIFIER_LABEL_VALUE (node), indent + 4);
    print_node (file, "template", IDENTIFIER_TEMPLATE (node), indent + 4);
-   print_node (file, "implicit", IDENTIFIER_IMPLICIT_DECL (node), indent + 4);
-   print_node (file, "error locus", IDENTIFIER_ERROR_LOCUS (node), indent + 4);
  }
  
  void
  cxx_print_xnode (FILE *file, tree node, int indent)
  {
--- 155,164 ----
Index: cp/search.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/search.c,v
retrieving revision 1.287
diff -c -5 -p -r1.287 search.c
*** cp/search.c	14 Feb 2004 00:49:12 -0000	1.287
--- cp/search.c	3 Mar 2004 02:12:22 -0000
*************** check_final_overrider (tree overrider, t
*** 1701,1711 ****
    tree over_return = TREE_TYPE (over_type);
    tree base_return = TREE_TYPE (base_type);
    tree over_throw = TYPE_RAISES_EXCEPTIONS (over_type);
    tree base_throw = TYPE_RAISES_EXCEPTIONS (base_type);
    int fail = 0;
!   
    if (same_type_p (base_return, over_return))
      /* OK */;
    else if ((CLASS_TYPE_P (over_return) && CLASS_TYPE_P (base_return))
  	   || (TREE_CODE (base_return) == TREE_CODE (over_return)
  	       && POINTER_TYPE_P (base_return)))
--- 1701,1714 ----
    tree over_return = TREE_TYPE (over_type);
    tree base_return = TREE_TYPE (base_type);
    tree over_throw = TYPE_RAISES_EXCEPTIONS (over_type);
    tree base_throw = TYPE_RAISES_EXCEPTIONS (base_type);
    int fail = 0;
! 
!   if (DECL_INVALID_OVERRIDER_P (overrider))
!     return 0;
! 
    if (same_type_p (base_return, over_return))
      /* OK */;
    else if ((CLASS_TYPE_P (over_return) && CLASS_TYPE_P (base_return))
  	   || (TREE_CODE (base_return) == TREE_CODE (over_return)
  	       && POINTER_TYPE_P (base_return)))
*************** check_final_overrider (tree overrider, t
*** 1751,1762 ****
      }
    else
      fail = 2;
    if (!fail)
      /* OK */;
-   else if (IDENTIFIER_ERROR_LOCUS (DECL_ASSEMBLER_NAME (overrider)))
-     return 0;
    else
      {
        if (fail == 1)
  	{
  	  cp_error_at ("invalid covariant return type for `%#D'", overrider);
--- 1754,1763 ----
*************** check_final_overrider (tree overrider, t
*** 1766,1790 ****
  	{
  	  cp_error_at ("conflicting return type specified for `%#D'",
  		       overrider);
  	  cp_error_at ("  overriding `%#D'", basefn);
  	}
!       SET_IDENTIFIER_ERROR_LOCUS (DECL_ASSEMBLER_NAME (overrider),
!                                   DECL_CONTEXT (overrider));
        return 0;
      }
    
    /* Check throw specifier is at least as strict.  */
    if (!comp_except_specs (base_throw, over_throw, 0))
      {
!       if (!IDENTIFIER_ERROR_LOCUS (DECL_ASSEMBLER_NAME (overrider)))
! 	{
! 	  cp_error_at ("looser throw specifier for `%#F'", overrider);
! 	  cp_error_at ("  overriding `%#F'", basefn);
! 	  SET_IDENTIFIER_ERROR_LOCUS (DECL_ASSEMBLER_NAME (overrider),
! 				      DECL_CONTEXT (overrider));
! 	}
        return 0;
      }
    
    return 1;
  }
--- 1767,1786 ----
  	{
  	  cp_error_at ("conflicting return type specified for `%#D'",
  		       overrider);
  	  cp_error_at ("  overriding `%#D'", basefn);
  	}
!       DECL_INVALID_OVERRIDER_P (overrider) = 1;
        return 0;
      }
    
    /* Check throw specifier is at least as strict.  */
    if (!comp_except_specs (base_throw, over_throw, 0))
      {
!       cp_error_at ("looser throw specifier for `%#F'", overrider);
!       cp_error_at ("  overriding `%#F'", basefn);
!       DECL_INVALID_OVERRIDER_P (overrider) = 1;
        return 0;
      }
    
    return 1;
  }
Index: cp/typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/typeck.c,v
retrieving revision 1.530
diff -c -5 -p -r1.530 typeck.c
*** cp/typeck.c	1 Mar 2004 02:25:04 -0000	1.530
--- cp/typeck.c	3 Mar 2004 02:12:22 -0000
*************** tree
*** 2378,2388 ****
  build_function_call (tree function, tree params)
  {
    tree fntype, fndecl;
    tree coerced_params;
    tree result;
!   tree name = NULL_TREE, assembler_name = NULL_TREE;
    int is_method;
    tree original = function;
  
    /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue.
       Strip such NOP_EXPRs, since FUNCTION is used in non-lvalue context.  */
--- 2378,2388 ----
  build_function_call (tree function, tree params)
  {
    tree fntype, fndecl;
    tree coerced_params;
    tree result;
!   tree name = NULL_TREE;
    int is_method;
    tree original = function;
  
    /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue.
       Strip such NOP_EXPRs, since FUNCTION is used in non-lvalue context.  */
*************** build_function_call (tree function, tree
*** 2391,2401 ****
      function = TREE_OPERAND (function, 0);
  
    if (TREE_CODE (function) == FUNCTION_DECL)
      {
        name = DECL_NAME (function);
-       assembler_name = DECL_ASSEMBLER_NAME (function);
  
        mark_used (function);
        fndecl = function;
  
        /* Convert anything with function type to a pointer-to-function.  */
--- 2391,2400 ----
Index: testsuite/g++.dg/lookup/koenig1.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/lookup/koenig1.C,v
retrieving revision 1.1
diff -c -5 -p -r1.1 koenig1.C
*** testsuite/g++.dg/lookup/koenig1.C	24 Mar 2003 18:20:12 -0000	1.1
--- testsuite/g++.dg/lookup/koenig1.C	3 Mar 2004 02:12:23 -0000
***************
*** 7,13 ****
  
  class X;
  
  void foo() {
    X x(1); // { dg-error "incomplete type" "" }
!   bar(x); // { dg-error "undeclared" "" }
  }
--- 7,13 ----
  
  class X;
  
  void foo() {
    X x(1); // { dg-error "incomplete type" "" }
!   bar(x); // { dg-error "not declared" "" }
  }
Index: testsuite/g++.dg/lookup/used-before-declaration.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/lookup/used-before-declaration.C,v
retrieving revision 1.1
diff -c -5 -p -r1.1 used-before-declaration.C
*** testsuite/g++.dg/lookup/used-before-declaration.C	10 Nov 2003 08:32:16 -0000	1.1
--- testsuite/g++.dg/lookup/used-before-declaration.C	3 Mar 2004 02:12:23 -0000
***************
*** 1,5 ****
  // Copyroght (C) 2003 Free Software Foundation
  // Origin: PR/12832, Jonathan Wakely <redi@gcc.gnu.org>
  
! void f() { g(); }               // { dg-error "undeclared" "" }
! void g() { }                    // { dg-error "used" "" }
--- 1,5 ----
  // Copyroght (C) 2003 Free Software Foundation
  // Origin: PR/12832, Jonathan Wakely <redi@gcc.gnu.org>
  
! void f() { g(); }               // { dg-error "not declared" "" }
! void g() { }
Index: testsuite/g++.dg/other/do1.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/other/do1.C,v
retrieving revision 1.3
diff -c -5 -p -r1.3 do1.C
*** testsuite/g++.dg/other/do1.C	28 Dec 2002 07:48:07 -0000	1.3
--- testsuite/g++.dg/other/do1.C	3 Mar 2004 02:12:23 -0000
***************
*** 6,13 ****
  // PR 7640. ICE.
  
  void init ()
  {
    do {  } while (0)
! 	    obj = 0; // { dg-error "expected|undeclared" "" }
       
  }
--- 6,13 ----
  // PR 7640. ICE.
  
  void init ()
  {
    do {  } while (0)
! 	    obj = 0; // { dg-error "expected|not declared" "" }
       
  }
Index: testsuite/g++.dg/overload/koenig1.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/overload/koenig1.C,v
retrieving revision 1.1
diff -c -5 -p -r1.1 koenig1.C
*** testsuite/g++.dg/overload/koenig1.C	13 Mar 2003 20:43:47 -0000	1.1
--- testsuite/g++.dg/overload/koenig1.C	3 Mar 2004 02:12:23 -0000
*************** struct B;
*** 11,18 ****
  
  void g ()
  {
    B *bp;
    N::A *ap;
!   f (bp);			// { dg-error "undeclared" }
    f (ap);
  }
--- 11,18 ----
  
  void g ()
  {
    B *bp;
    N::A *ap;
!   f (bp);			// { dg-error "not declared" }
    f (ap);
  }
Index: testsuite/g++.dg/parse/crash13.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/parse/crash13.C,v
retrieving revision 1.1
diff -c -5 -p -r1.1 crash13.C
*** testsuite/g++.dg/parse/crash13.C	20 Oct 2003 12:42:37 -0000	1.1
--- testsuite/g++.dg/parse/crash13.C	3 Mar 2004 02:12:23 -0000
*************** void func(A<T>::B* )	// { dg-error "vari
*** 16,22 ****
  {			// { dg-error ";" }
  }
  
  int main() 
  {
!   func<void>(0);	// { dg-error "undeclared|expression|;" }
  }
--- 16,22 ----
  {			// { dg-error ";" }
  }
  
  int main() 
  {
!   func<void>(0);	// { dg-error "not declared|expression|;" }
  }
Index: testsuite/g++.dg/template/instantiate3.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/template/instantiate3.C,v
retrieving revision 1.2
diff -c -5 -p -r1.2 instantiate3.C
*** testsuite/g++.dg/template/instantiate3.C	28 Dec 2002 07:48:08 -0000	1.2
--- testsuite/g++.dg/template/instantiate3.C	3 Mar 2004 02:12:24 -0000
*************** class ACE_Null_Mutex;	// { dg-error "for
*** 8,17 ****
  
  template <class TYPE>
  struct ACE_Cleanup_Adapter
  {
    TYPE &object ()
!   { return object_; }	// { dg-error "undeclared|reported" }
    TYPE object_;		// { dg-error "incomplete type" }
  };
  
  template class ACE_Cleanup_Adapter<ACE_Null_Mutex>; // { dg-error "instantiated from here" }
--- 8,17 ----
  
  template <class TYPE>
  struct ACE_Cleanup_Adapter
  {
    TYPE &object ()
!   { return object_; }	// { dg-error "not declared|reported" }
    TYPE object_;		// { dg-error "incomplete type" }
  };
  
  template class ACE_Cleanup_Adapter<ACE_Null_Mutex>; // { dg-error "instantiated from here" }


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