PATCH to C++ diagnostic/pretty printer

Gabriel Dos Reis gdr@cs.tamu.edu
Fri Mar 23 04:36:00 GMT 2007


hi,

  The patchlet below fixes a couple of misuses of of diagnostic
format specifier in the C++ front end, as well as a missing case.
That takes care of a couple of diagnostic PRs.

-- Gaby

2007-03-22  Gabriel Dos Reis  <gdr@integrable-solutions.net>

	* error.c (dump_expr): Handle dependent names that designate types.
	* cxx-pretty-print.c (pp_cxx_unqualified_id): Handle TYPENAME_TYPE.

*** cp/cxx-pretty-print.c	(revision 123149)
--- cp/cxx-pretty-print.c	(local)
*************** pp_cxx_template_id (cxx_pretty_printer *
*** 129,135 ****
    pp_cxx_end_template_argument_list (pp);
  }
  
! /* unqualified-id:
       identifier
       operator-function-id
       conversion-function-id
--- 129,137 ----
    pp_cxx_end_template_argument_list (pp);
  }
  
! /* Prints the unqualified part of the id-expression T.
! 
!    unqualified-id:
       identifier
       operator-function-id
       conversion-function-id
*************** pp_cxx_unqualified_id (cxx_pretty_printe
*** 204,209 ****
--- 206,215 ----
        pp_cxx_unqualified_id (pp, TEMPLATE_PARM_DECL (t));
        break;
  
+     case TYPENAME_TYPE:
+       pp_cxx_unqualified_id (pp, TYPE_NAME (t));
+       break;
+ 
      default:
        pp_unsupported_tree (pp, t);
        break;
*** cp/error.c	(revision 123149)
--- cp/error.c	(local)
*************** dump_expr (tree t, int flags)
*** 1987,1992 ****
--- 1987,2010 ----
        pp_cxx_identifier (cxx_pp, "...");
        break;
  
+     case RECORD_TYPE:
+     case UNION_TYPE:
+     case ENUMERAL_TYPE:
+     case REAL_TYPE:
+     case VOID_TYPE:
+     case BOOLEAN_TYPE:
+     case INTEGER_TYPE:
+     case COMPLEX_TYPE:
+     case VECTOR_TYPE:
+       pp_type_specifier_seq (cxx_pp, t);
+       break;
+ 
+     case TYPENAME_TYPE:
+       /* We get here when we want to print a dependent type as an
+          id-expression, without any disambiguator decoration.  */
+       pp_id_expression (cxx_pp, t);
+       break;
+ 
        /*  This list is incomplete, but should suffice for now.
  	  It is very important that `sorry' does not call
  	  `report_error_function'.  That could cause an infinite loop.  */
*** cp/parser.c	(revision 123149)
--- cp/parser.c	(local)
*************** cp_parser_name_lookup_error (cp_parser* 
*** 2054,2079 ****
    if (decl == error_mark_node)
      {
        if (parser->scope && parser->scope != global_namespace)
! 	error ("%<%D::%D%> has not been declared",
  	       parser->scope, name);
        else if (parser->scope == global_namespace)
! 	error ("%<::%D%> has not been declared", name);
        else if (parser->object_scope
  	       && !CLASS_TYPE_P (parser->object_scope))
! 	error ("request for member %qD in non-class type %qT",
  	       name, parser->object_scope);
        else if (parser->object_scope)
! 	error ("%<%T::%D%> has not been declared",
  	       parser->object_scope, name);
        else
! 	error ("%qD has not been declared", name);
      }
    else if (parser->scope && parser->scope != global_namespace)
!     error ("%<%D::%D%> %s", parser->scope, name, desired);
    else if (parser->scope == global_namespace)
!     error ("%<::%D%> %s", name, desired);
    else
!     error ("%qD %s", name, desired);
  }
  
  /* If we are parsing tentatively, remember that an error has occurred
--- 2054,2079 ----
    if (decl == error_mark_node)
      {
        if (parser->scope && parser->scope != global_namespace)
! 	error ("%<%E::%E%> has not been declared",
  	       parser->scope, name);
        else if (parser->scope == global_namespace)
! 	error ("%<::%E%> has not been declared", name);
        else if (parser->object_scope
  	       && !CLASS_TYPE_P (parser->object_scope))
! 	error ("request for member %qE in non-class type %qT",
  	       name, parser->object_scope);
        else if (parser->object_scope)
! 	error ("%<%T::%E%> has not been declared",
  	       parser->object_scope, name);
        else
! 	error ("%qE has not been declared", name);
      }
    else if (parser->scope && parser->scope != global_namespace)
!     error ("%<%E::%E%> %s", parser->scope, name, desired);
    else if (parser->scope == global_namespace)
!     error ("%<::%E%> %s", name, desired);
    else
!     error ("%qE %s", name, desired);
  }
  
  /* If we are parsing tentatively, remember that an error has occurred
*************** cp_parser_direct_declarator (cp_parser* 
*** 12176,12182 ****
  					    /*only_current_p=*/false);
  	      /* If that failed, the declarator is invalid.  */
  	      if (type == error_mark_node)
! 		error ("%<%T::%D%> is not a type",
  		       TYPE_CONTEXT (qualifying_scope),
  		       TYPE_IDENTIFIER (qualifying_scope));
  	      qualifying_scope = type;
--- 12176,12182 ----
  					    /*only_current_p=*/false);
  	      /* If that failed, the declarator is invalid.  */
  	      if (type == error_mark_node)
! 		error ("%<%T::%E%> is not a type",
  		       TYPE_CONTEXT (qualifying_scope),
  		       TYPE_IDENTIFIER (qualifying_scope));
  	      qualifying_scope = type;



More information about the Gcc-patches mailing list