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]

Re: C++ diagnostics: Use quoting flag q (7/n)


"Joseph S. Myers" <jsm@polyomino.org.uk> writes:

| On Sun, 10 Oct 2004, Gabriel Dos Reis wrote:
| 
| > This is assumed to finish the conversion of the C++ front-end to use
| > the newly recommended quotation marks.  Any remaining old-style
| > quotations is now officially considered a bug.
| 
| And likewise also cases of e.g. %D with no quoting?
| 
| Some cases of both or of stray ` that seem to be left:

Fixed with this.

I think I got all of them.

-- Gaby

2004-10-31  Gabriel Dos Reis  <gdr@integrable-solutions.net>

        Convert diagnostics to use quoting flag q 9/n
        * typeck.c (build_x_unary_op, convert_member_func_to_ptr, 
        get_delta_difference):  Use new quotation style.
        * repo.c (reopen_repo_file_for_write): Likewise.
        * pt.c (do_type_instantiation): Likewise.
        * parser.c (cp_parser_diagnose_invalid_type_name): 
        * name-lookup.c (push_overloaded_decl, set_decl_namespace): 
        * error.c (cp_print_error_function,
        print_instantiation_full_context): Likewise.
        * decl.c (define_label, grok_reference_init, 
        maybe_deduce_size_from_array_init, revert_static_member_fn): 
        * decl2.c (check_classfn): Likewise.
        * class.c (add_method, check_field_decls, layout_class_type, 
        resolve_address_of_overloaded_function): Likewise.
        * call.c (build_x_va_arg, build_over_call): Likewise.
  
Index: call.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/call.c,v
retrieving revision 1.517
diff -p -r1.517 call.c
*** call.c	28 Oct 2004 05:17:08 -0000	1.517
--- call.c	1 Nov 2004 09:46:07 -0000
*************** build_x_va_arg (tree expr, tree type)
*** 4429,4435 ****
    if (! pod_type_p (type))
      {
        /* Undefined behavior [expr.call] 5.2.2/7.  */
!       warning ("cannot receive objects of non-POD type %q#T' through %<...%>; "
                 "call will abort at runtime", type);
        expr = convert (build_pointer_type (type), null_node);
        expr = build2 (COMPOUND_EXPR, TREE_TYPE (expr),
--- 4429,4435 ----
    if (! pod_type_p (type))
      {
        /* Undefined behavior [expr.call] 5.2.2/7.  */
!       warning ("cannot receive objects of non-POD type %q#T through %<...%>; "
                 "call will abort at runtime", type);
        expr = convert (build_pointer_type (type), null_node);
        expr = build2 (COMPOUND_EXPR, TREE_TYPE (expr),
*************** build_over_call (struct z_candidate *can
*** 4677,4684 ****
        tree base_binfo;
        
        if (convs[i]->bad_p)
! 	pedwarn ("passing `%T' as `this' argument of `%#D' discards qualifiers",
! 		    TREE_TYPE (argtype), fn);
  
        /* [class.mfct.nonstatic]: If a nonstatic member function of a class
  	 X is called for an object that is not of type X, or of a type
--- 4677,4684 ----
        tree base_binfo;
        
        if (convs[i]->bad_p)
! 	pedwarn ("passing %qT as %<this%> argument of %q#D discards qualifiers",
!                  TREE_TYPE (argtype), fn);
  
        /* [class.mfct.nonstatic]: If a nonstatic member function of a class
  	 X is called for an object that is not of type X, or of a type
Index: class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/class.c,v
retrieving revision 1.686
diff -p -r1.686 class.c
*** class.c	21 Oct 2004 21:23:38 -0000	1.686
--- class.c	1 Nov 2004 09:46:12 -0000
*************** add_method (tree type, tree method)
*** 995,1001 ****
  		return;
  	      else
  		{
! 		  cp_error_at ("`%#D' and `%#D' cannot be overloaded",
  			       method, fn);
  
  		  /* We don't call duplicate_decls here to merge
--- 995,1001 ----
  		return;
  	      else
  		{
! 		  cp_error_at ("%q#D and %q#D cannot be overloaded",
  			       method, fn);
  
  		  /* We don't call duplicate_decls here to merge
*************** check_field_decls (tree t, tree *access_
*** 2872,2878 ****
  	    }
  	  if (TREE_CODE (type) == REFERENCE_TYPE)
  	    {
! 	      cp_error_at ("%qD may not have reference type `%T' because it is a member of a union",
  			   x, type);
  	      continue;
  	    }
--- 2872,2879 ----
  	    }
  	  if (TREE_CODE (type) == REFERENCE_TYPE)
  	    {
! 	      cp_error_at ("%qD may not have reference type %qT because"
!                            " it is a member of a union",
  			   x, type);
  	      continue;
  	    }
*************** layout_class_type (tree t, tree *virtual
*** 4599,4605 ****
  	      else
  		{
  		  if (warn_abi && TREE_CODE (t) == UNION_TYPE)
! 		    warning ("size assigned to `%T' may not be "
  			     "ABI-compliant and may change in a future "
  			     "version of GCC", 
  			     t);
--- 4600,4606 ----
  	      else
  		{
  		  if (warn_abi && TREE_CODE (t) == UNION_TYPE)
! 		    warning ("size assigned to %qT may not be "
  			     "ABI-compliant and may change in a future "
  			     "version of GCC", 
  			     t);
*************** resolve_address_of_overloaded_function (
*** 5615,5623 ****
    else 
      {
        if (flags & tf_error)
! 	error ("\
! cannot resolve overloaded function `%D' based on conversion to type `%T'", 
! 		  DECL_NAME (OVL_FUNCTION (overload)), target_type);
        return error_mark_node;
      }
    
--- 5616,5624 ----
    else 
      {
        if (flags & tf_error)
! 	error ("cannot resolve overloaded function %qD based on"
!                " conversion to type %qT", 
!                DECL_NAME (OVL_FUNCTION (overload)), target_type);
        return error_mark_node;
      }
    
Index: decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1323
diff -p -r1.1323 decl.c
*** decl.c	30 Oct 2004 21:17:28 -0000	1.1323
--- decl.c	1 Nov 2004 09:46:18 -0000
*************** define_label (location_t location, tree 
*** 2416,2422 ****
      pedwarn ("label named wchar_t");
  
    if (DECL_INITIAL (decl) != NULL_TREE)
!     error ("duplicate label `%D'", decl);
    else
      {
        /* Mark label as having been defined.  */
--- 2416,2422 ----
      pedwarn ("label named wchar_t");
  
    if (DECL_INITIAL (decl) != NULL_TREE)
!     error ("duplicate label %qD", decl);
    else
      {
        /* Mark label as having been defined.  */
*************** grok_reference_init (tree decl, tree typ
*** 3936,3942 ****
        if ((DECL_LANG_SPECIFIC (decl) == 0
  	   || DECL_IN_AGGR_P (decl) == 0)
  	  && ! DECL_THIS_EXTERN (decl))
! 	error ("`%D' declared as reference but not initialized", decl);
        return NULL_TREE;
      }
  
--- 3936,3942 ----
        if ((DECL_LANG_SPECIFIC (decl) == 0
  	   || DECL_IN_AGGR_P (decl) == 0)
  	  && ! DECL_THIS_EXTERN (decl))
! 	error ("%qD declared as reference but not initialized", decl);
        return NULL_TREE;
      }
  
*************** maybe_deduce_size_from_array_init (tree 
*** 4008,4014 ****
        if (failure == 2)
  	{
  	  if (do_default)
! 	    error ("array size missing in `%D'", decl);
  	  /* If a `static' var's size isn't known, make it extern as
  	     well as static, so it does not get allocated.  If it's not
  	     `static', then don't mark it extern; finish_incomplete_decl
--- 4008,4014 ----
        if (failure == 2)
  	{
  	  if (do_default)
! 	    error ("array size missing in %qD", decl);
  	  /* If a `static' var's size isn't known, make it extern as
  	     well as static, so it does not get allocated.  If it's not
  	     `static', then don't mark it extern; finish_incomplete_decl
*************** revert_static_member_fn (tree decl)
*** 10970,10977 ****
  
    if (cp_type_quals (TREE_TYPE (TREE_VALUE (args)))
        != TYPE_UNQUALIFIED)
!     error ("static member function `%#D' declared with type qualifiers",
! 	      decl);
  
    args = TREE_CHAIN (args);
    tmp = build_function_type (TREE_TYPE (function), args);
--- 10970,10976 ----
  
    if (cp_type_quals (TREE_TYPE (TREE_VALUE (args)))
        != TYPE_UNQUALIFIED)
!     error ("static member function %q#D declared with type qualifiers", decl);
  
    args = TREE_CHAIN (args);
    tmp = build_function_type (TREE_TYPE (function), args);
Index: decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.754
diff -p -r1.754 decl2.c
*** decl2.c	17 Oct 2004 04:39:44 -0000	1.754
--- decl2.c	1 Nov 2004 09:46:19 -0000
*************** check_classfn (tree ctype, tree function
*** 674,680 ****
  	pop_scope (ctype);
        if (fndecls)
  	return OVL_CURRENT (fndecls);
!       error ("prototype for `%#D' does not match any in class `%T'",
  	     function, ctype);
        is_conv_op = DECL_CONV_FN_P (fndecl);
  
--- 674,680 ----
  	pop_scope (ctype);
        if (fndecls)
  	return OVL_CURRENT (fndecls);
!       error ("prototype for %q#D does not match any in class %qT",
  	     function, ctype);
        is_conv_op = DECL_CONV_FN_P (fndecl);
  
Index: error.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/error.c,v
retrieving revision 1.269
diff -p -r1.269 error.c
*** error.c	30 Oct 2004 21:17:29 -0000	1.269
--- error.c	1 Nov 2004 09:46:20 -0000
*************** cp_print_error_function (diagnostic_cont
*** 2152,2158 ****
        if (current_function_decl == NULL)
          pp_base_string (context->printer, "At global scope:");
        else
!         pp_printf (context->printer, "In %s `%s':",
                     function_category (current_function_decl),
                     cxx_printable_name (current_function_decl, 2));
        pp_base_newline (context->printer);
--- 2152,2158 ----
        if (current_function_decl == NULL)
          pp_base_string (context->printer, "At global scope:");
        else
!         pp_printf (context->printer, "In %s %qs:",
                     function_category (current_function_decl),
                     cxx_printable_name (current_function_decl, 2));
        pp_base_newline (context->printer);
*************** print_instantiation_full_context (diagno
*** 2206,2212 ****
  	    /* Avoid redundancy with the the "In function" line.  */;
  	  else
  	    pp_verbatim (context->printer,
!                          "%s: In instantiation of `%s':\n",
  			 LOCATION_FILE (location),
                           decl_as_string (TINST_DECL (p),
                                           TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE));
--- 2206,2212 ----
  	    /* Avoid redundancy with the the "In function" line.  */;
  	  else
  	    pp_verbatim (context->printer,
!                          "%s: In instantiation of %qs:\n",
  			 LOCATION_FILE (location),
                           decl_as_string (TINST_DECL (p),
                                           TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE));
Index: name-lookup.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/name-lookup.c,v
retrieving revision 1.89
diff -p -r1.89 name-lookup.c
*** name-lookup.c	27 Oct 2004 05:51:24 -0000	1.89
--- name-lookup.c	1 Nov 2004 09:46:23 -0000
*************** push_overloaded_decl (tree decl, int fla
*** 2008,2014 ****
  	  if (IS_AGGR_TYPE (t) && warn_shadow
  	      && (! DECL_IN_SYSTEM_HEADER (decl)
  		  || ! DECL_IN_SYSTEM_HEADER (old)))
! 	    warning ("`%#D' hides constructor for `%#T'", decl, t);
  	  old = NULL_TREE;
  	}
        else if (is_overloaded_fn (old))
--- 2008,2014 ----
  	  if (IS_AGGR_TYPE (t) && warn_shadow
  	      && (! DECL_IN_SYSTEM_HEADER (decl)
  		  || ! DECL_IN_SYSTEM_HEADER (old)))
! 	    warning ("%q#D hides constructor for %q#T", decl, t);
  	  old = NULL_TREE;
  	}
        else if (is_overloaded_fn (old))
*************** set_decl_namespace (tree decl, tree scop
*** 3000,3007 ****
    
    /* It is ok for friends to be qualified in parallel space.  */
    if (!friendp && !is_ancestor (current_namespace, scope))
!     error ("declaration of `%D' not in a namespace surrounding `%D'",
! 	      decl, scope);
    DECL_CONTEXT (decl) = FROB_CONTEXT (scope);
    if (scope != current_namespace)
      {
--- 3000,3007 ----
    
    /* It is ok for friends to be qualified in parallel space.  */
    if (!friendp && !is_ancestor (current_namespace, scope))
!     error ("declaration of %qD not in a namespace surrounding %qD",
!            decl, scope);
    DECL_CONTEXT (decl) = FROB_CONTEXT (scope);
    if (scope != current_namespace)
      {
Index: parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.274
diff -p -r1.274 parser.c
*** parser.c	29 Oct 2004 00:50:41 -0000	1.274
--- parser.c	1 Nov 2004 09:46:30 -0000
*************** cp_parser_diagnose_invalid_type_name (cp
*** 1990,1996 ****
  		    if (TREE_CODE (field) == TYPE_DECL
  			&& DECL_NAME (field) == id)
  		      {
! 			inform ("(perhaps `typename %T::%E' was intended)",
  			        BINFO_TYPE (b), id);
  			break;
  		      }
--- 1990,1996 ----
  		    if (TREE_CODE (field) == TYPE_DECL
  			&& DECL_NAME (field) == id)
  		      {
! 			inform ("(perhaps %<typename %T::%E%> was intended)",
  			        BINFO_TYPE (b), id);
  			break;
  		      }
Index: pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.940
diff -p -r1.940 pt.c
*** pt.c	29 Oct 2004 14:10:24 -0000	1.940
--- pt.c	1 Nov 2004 09:46:37 -0000
*************** do_type_instantiation (tree t, tree stor
*** 10843,10849 ****
    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])
--- 10843,10849 ----
    if (storage != NULL_TREE)
      {
        if (pedantic && !in_system_header)
! 	pedwarn("ISO C++ forbids the use of %qE on explicit instantiations", 
                  storage);
  
        if (storage == ridpointers[(int) RID_INLINE])
Index: repo.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/repo.c,v
retrieving revision 1.53
diff -p -r1.53 repo.c
*** repo.c	15 Oct 2004 14:49:30 -0000	1.53
--- repo.c	1 Nov 2004 09:46:37 -0000
*************** reopen_repo_file_for_write (void)
*** 211,217 ****
  
    if (repo_file == 0)
      {
!       error ("can't create repository information file `%s'", repo_name);
        flag_use_repository = 0;
      }
  }
--- 211,217 ----
  
    if (repo_file == 0)
      {
!       error ("can't create repository information file %qs", repo_name);
        flag_use_repository = 0;
      }
  }
Index: typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/typeck.c,v
retrieving revision 1.590
diff -p -r1.590 typeck.c
*** typeck.c	29 Oct 2004 08:35:43 -0000	1.590
--- typeck.c	1 Nov 2004 09:46:40 -0000
*************** build_x_unary_op (enum tree_code code, t
*** 3620,3632 ****
  	{
  	  if (TREE_CODE (xarg) != OFFSET_REF)
  	    {
! 	      error ("invalid use of '%E' to form a pointer-to-member-function.  Use a qualified-id.",
  		     xarg);
  	      return error_mark_node;
  	    }
  	  else
  	    {
! 	      error ("parenthesis around '%E' cannot be used to form a pointer-to-member-function",
  		     xarg);
  	      PTRMEM_OK_P (xarg) = 1;
  	    }
--- 3620,3634 ----
  	{
  	  if (TREE_CODE (xarg) != OFFSET_REF)
  	    {
! 	      error ("invalid use of %qE to form a pointer-to-member-function."
!                      "  Use a qualified-id.",
  		     xarg);
  	      return error_mark_node;
  	    }
  	  else
  	    {
! 	      error ("parenthesis around %qE cannot be used to form a"
!                      " pointer-to-member-function",
  		     xarg);
  	      PTRMEM_OK_P (xarg) = 1;
  	    }
*************** convert_member_func_to_ptr (tree type, t
*** 4802,4808 ****
  	      || TREE_CODE (intype) == METHOD_TYPE);
  
    if (pedantic || warn_pmf2ptr)
!     pedwarn ("converting from `%T' to `%T'", intype, type);
      
    if (TREE_CODE (intype) == METHOD_TYPE)
      expr = build_addr_func (expr);
--- 4804,4810 ----
  	      || TREE_CODE (intype) == METHOD_TYPE);
  
    if (pedantic || warn_pmf2ptr)
!     pedwarn ("converting from %qT to %qT", intype, type);
      
    if (TREE_CODE (intype) == METHOD_TYPE)
      expr = build_addr_func (expr);
*************** get_delta_difference (tree from, tree to
*** 5595,5601 ****
  	      virt_binfo = binfo_from_vbase (binfo);
  	      if (virt_binfo)
  		/* This is a reinterpret cast, we choose to do nothing.  */
! 		warning ("pointer to member cast via virtual base `%T'",
  			 BINFO_TYPE (virt_binfo));
  	      else
  		result = size_diffop (size_zero_node, BINFO_OFFSET (binfo));
--- 5597,5603 ----
  	      virt_binfo = binfo_from_vbase (binfo);
  	      if (virt_binfo)
  		/* This is a reinterpret cast, we choose to do nothing.  */
! 		warning ("pointer to member cast via virtual base %qT",
  			 BINFO_TYPE (virt_binfo));
  	      else
  		result = size_diffop (size_zero_node, BINFO_OFFSET (binfo));


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