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: Use %E to format IDENTIFIER_NODEs


As recently discussed in the context of a contribution (I dont have a
link to handy), this makes the C++ front-end use %E to format
IDENTIFIER_NODEs, insteading of peeking at the IDENTIFIER_POINTER.

Regtested on an i686-pc-linux-gnu.

-- Gaby

Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/ChangeLog,v
retrieving revision 1.4052
diff -p -r1.4052 ChangeLog
*** ChangeLog	22 May 2004 21:45:17 -0000	1.4052
--- ChangeLog	23 May 2004 10:34:10 -0000
***************
*** 1,3 ****
--- 1,16 ----
+ 2004-05-23  Gabriel Dos Reis  <gdr@integrable-solutions.net>
+ 
+ 	* class.c (alter_access): Use %E format specifier to print an
+ 	identifier node.  Avoid looking at the IDENTIFIER_POINTER.
+ 	(push_lang_context): Likewise.
+ 	* decl.c (lookup_label): Likewise.
+ 	(grokdeclarator): Likewise.
+ 	* parser.c (cp_parser_check_for_invalid_template_id): Likewise.
+ 	* pt.c (do_type_instantiation): Likewise.
+ 	* tree.c (handle_java_interface_attribute): Likewise.
+ 	(handle_com_interface_attribute): Likewise.
+ 	(handle_init_priority_attribute): Likewise.
+ 
  2004-05-22  Mark Mitchell  <mark@codesourcery.com>
  
  	PR c++/15285
Index: class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/class.c,v
retrieving revision 1.613
diff -p -r1.613 class.c
*** class.c	22 May 2004 19:28:28 -0000	1.613
--- class.c	23 May 2004 10:34:15 -0000
*************** alter_access (tree t, tree fdecl, tree a
*** 1055,1062 ****
  	  if (TREE_CODE (TREE_TYPE (fdecl)) == FUNCTION_DECL)
  	    cp_error_at ("conflicting access specifications for method `%D', ignored", TREE_TYPE (fdecl));
  	  else
! 	    error ("conflicting access specifications for field `%s', ignored",
! 		   IDENTIFIER_POINTER (DECL_NAME (fdecl)));
  	}
        else
  	{
--- 1055,1062 ----
  	  if (TREE_CODE (TREE_TYPE (fdecl)) == FUNCTION_DECL)
  	    cp_error_at ("conflicting access specifications for method `%D', ignored", TREE_TYPE (fdecl));
  	  else
! 	    error ("conflicting access specifications for field `%E', ignored",
! 		   DECL_NAME (fdecl));
  	}
        else
  	{
*************** push_lang_context (tree name)
*** 5706,5712 ****
        current_lang_name = name;
      }
    else
!     error ("language string `\"%s\"' not recognized", IDENTIFIER_POINTER (name));
  }
    
  /* Get out of the current language scope.  */
--- 5706,5712 ----
        current_lang_name = name;
      }
    else
!     error ("language string `\"%E\"' not recognized", name);
  }
    
  /* Get out of the current language scope.  */
Index: decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1208
diff -p -r1.1208 decl.c
*** decl.c	20 May 2004 11:36:14 -0000	1.1208
--- decl.c	23 May 2004 10:34:22 -0000
*************** lookup_label (tree id)
*** 2066,2073 ****
    /* You can't use labels at global scope.  */
    if (current_function_decl == NULL_TREE)
      {
!       error ("label `%s' referenced outside of any function",
! 	     IDENTIFIER_POINTER (id));
        POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE);
      }
  
--- 2066,2072 ----
    /* You can't use labels at global scope.  */
    if (current_function_decl == NULL_TREE)
      {
!       error ("label `%E' referenced outside of any function", id);
        POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE);
      }
  
*************** grokdeclarator (tree declarator,
*** 6746,6752 ****
  			longlong = 1;
  		    }
  		  else if (RIDBIT_SETP (i, specbits))
! 		    pedwarn ("duplicate `%s'", IDENTIFIER_POINTER (id));
  
  		  /* Diagnose "__thread extern" or "__thread static".  */
  		  if (RIDBIT_SETP (RID_THREAD, specbits))
--- 6745,6751 ----
  			longlong = 1;
  		    }
  		  else if (RIDBIT_SETP (i, specbits))
! 		    pedwarn ("duplicate `%E'", id);
  
  		  /* Diagnose "__thread extern" or "__thread static".  */
  		  if (RIDBIT_SETP (RID_THREAD, specbits))
*************** grokdeclarator (tree declarator,
*** 6786,6793 ****
  	{
  	  tree t = lookup_name (id, 1);
  	  if (!t || TREE_CODE (t) != TYPE_DECL)
! 	    error ("`%s' fails to be a typedef or built in type",
! 		   IDENTIFIER_POINTER (id));
  	  else
  	    {
  	      type = TREE_TYPE (t);
--- 6785,6791 ----
  	{
  	  tree t = lookup_name (id, 1);
  	  if (!t || TREE_CODE (t) != TYPE_DECL)
! 	    error ("`%E' fails to be a typedef or built in type", id);
  	  else
  	    {
  	      type = TREE_TYPE (t);
*************** grokdeclarator (tree declarator,
*** 7343,7350 ****
  		      error ("destructor cannot be static member function");
  		    if (quals)
  		      {
! 			error ("destructors may not be `%s'",
! 				  IDENTIFIER_POINTER (TREE_VALUE (quals)));
  			quals = NULL_TREE;
  		      }
  		    if (decl_context == FIELD)
--- 7341,7348 ----
  		      error ("destructor cannot be static member function");
  		    if (quals)
  		      {
! 			error ("destructors may not be `%E'",
! 				  TREE_VALUE (quals));
  			quals = NULL_TREE;
  		      }
  		    if (decl_context == FIELD)
*************** grokdeclarator (tree declarator,
*** 7372,7379 ****
  		      }
  		    if (quals)
  		      {
! 			error ("constructors may not be `%s'",
! 				  IDENTIFIER_POINTER (TREE_VALUE (quals)));
  			quals = NULL_TREE;
  		      }
  		    {
--- 7370,7377 ----
  		      }
  		    if (quals)
  		      {
! 			error ("constructors may not be `%E'",
!                                TREE_VALUE (quals));
  			quals = NULL_TREE;
  		      }
  		    {
*************** grokdeclarator (tree declarator,
*** 8179,8186 ****
  	  {
  	    if (friendp)
  	      {
! 		error ("`%s' is neither function nor member function; cannot be declared friend",
! 		       IDENTIFIER_POINTER (declarator));
  		friendp = 0;
  	      }
  	    decl = NULL_TREE;
--- 8177,8184 ----
  	  {
  	    if (friendp)
  	      {
! 		error ("`%E' is neither function nor member function; "
!                        "cannot be declared friend", declarator);
  		friendp = 0;
  	      }
  	    decl = NULL_TREE;
Index: parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.192
diff -p -r1.192 parser.c
*** parser.c	13 May 2004 06:40:19 -0000	1.192
--- parser.c	23 May 2004 10:34:28 -0000
*************** cp_parser_check_for_invalid_template_id 
*** 1891,1897 ****
        if (TYPE_P (type))
  	error ("`%T' is not a template", type);
        else if (TREE_CODE (type) == IDENTIFIER_NODE)
! 	error ("`%s' is not a template", IDENTIFIER_POINTER (type));
        else
  	error ("invalid template-id");
        /* Remember the location of the invalid "<".  */
--- 1891,1897 ----
        if (TYPE_P (type))
  	error ("`%T' is not a template", type);
        else if (TREE_CODE (type) == IDENTIFIER_NODE)
! 	error ("`%E' is not a template", type);
        else
  	error ("invalid template-id");
        /* Remember the location of the invalid "<".  */
Index: pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.852
diff -p -r1.852 pt.c
*** pt.c	22 May 2004 21:45:19 -0000	1.852
--- pt.c	23 May 2004 10:34:34 -0000
*************** do_type_instantiation (tree t, tree stor
*** 10698,10705 ****
    if (storage != NULL_TREE)
      {
        if (pedantic && !in_system_header)
! 	pedwarn("ISO C++ forbids the use of `%s' on explicit instantiations", 
! 		   IDENTIFIER_POINTER (storage));
  
        if (storage == ridpointers[(int) RID_INLINE])
  	nomem_p = 1;
--- 10698,10705 ----
    if (storage != NULL_TREE)
      {
        if (pedantic && !in_system_header)
! 	pedwarn("ISO C++ forbids the use of `%E' on explicit instantiations", 
!                 storage);
  
        if (storage == ridpointers[(int) RID_INLINE])
  	nomem_p = 1;
Index: tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/tree.c,v
retrieving revision 1.373
diff -p -r1.373 tree.c
*** tree.c	13 May 2004 06:40:22 -0000	1.373
--- tree.c	23 May 2004 10:34:35 -0000
*************** handle_java_interface_attribute (tree* n
*** 1811,1818 ****
        || !CLASS_TYPE_P (*node)
        || !TYPE_FOR_JAVA (*node))
      {
!       error ("`%s' attribute can only be applied to Java class definitions",
! 	     IDENTIFIER_POINTER (name));
        *no_add_attrs = true;
        return NULL_TREE;
      }
--- 1811,1818 ----
        || !CLASS_TYPE_P (*node)
        || !TYPE_FOR_JAVA (*node))
      {
!       error ("`%E' attribute can only be applied to Java class definitions",
! 	     name);
        *no_add_attrs = true;
        return NULL_TREE;
      }
*************** handle_com_interface_attribute (tree* no
*** 1840,1853 ****
        || !CLASS_TYPE_P (*node)
        || *node != TYPE_MAIN_VARIANT (*node))
      {
!       warning ("`%s' attribute can only be applied to class definitions",
! 	       IDENTIFIER_POINTER (name));
        return NULL_TREE;
      }
  
    if (!warned++)
!     warning ("`%s' is obsolete; g++ vtables are now COM-compatible by default",
! 	     IDENTIFIER_POINTER (name));
  
    return NULL_TREE;
  }
--- 1840,1853 ----
        || !CLASS_TYPE_P (*node)
        || *node != TYPE_MAIN_VARIANT (*node))
      {
!       warning ("`%E' attribute can only be applied to class definitions",
! 	       name);
        return NULL_TREE;
      }
  
    if (!warned++)
!     warning ("`%E' is obsolete; g++ vtables are now COM-compatible by default",
! 	     name);
  
    return NULL_TREE;
  }
*************** handle_init_priority_attribute (tree* no
*** 1891,1898 ****
  	 init_priority value, so don't allow it.  */
        || current_function_decl) 
      {
!       error ("can only use `%s' attribute on file-scope definitions of objects of class type",
! 	     IDENTIFIER_POINTER (name));
        *no_add_attrs = true;
        return NULL_TREE;
      }
--- 1891,1898 ----
  	 init_priority value, so don't allow it.  */
        || current_function_decl) 
      {
!       error ("can only use `%E' attribute on file-scope definitions "
!              "of objects of class type", name);
        *no_add_attrs = true;
        return NULL_TREE;
      }
*************** handle_init_priority_attribute (tree* no
*** 1919,1926 ****
      }
    else
      {
!       error ("`%s' attribute is not supported on this platform",
! 	     IDENTIFIER_POINTER (name));
        *no_add_attrs = true;
        return NULL_TREE;
      }
--- 1919,1925 ----
      }
    else
      {
!       error ("`%E' attribute is not supported on this platform", name);
        *no_add_attrs = true;
        return NULL_TREE;
      }


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