PATCH to cleanup error report stuff (1/2)

Gabriel Dos Reis gdr@codesourcery.com
Wed Jan 19 10:44:00 GMT 2000


Mark Mitchell <mark@codesourcery.com> writes:

| >>>>> "Nathan" == Nathan Sidwell <nathan@acm.org> writes:
| 
|     Nathan> Gabriel Dos Reis wrote:
|     >> This patch inaugures a series of patches intended to update the
|     >> diagnostics related subroutines calls, subsequent to the
|     >> automatic line-wrapping mode implementation in g++.
| 
|     Nathan> Excellent!
| 
|     Nathan> conversion type character `T' in format typeck.c:4706:
|     Nathan> warning: unknown conversion type character `D' in format
|     Nathan> typeck.c:4706: warning: too many arguments for format
|     Nathan> typeck.c:4710: warning: too many arguments for format
| 
| Good spotting -- I should have seen this when I reviewed the patch,
| but didn't.  Gaby, please submit a patch to fix these up.

I messed up pedwarn() and cp_pedwarn() :-(

|     Nathan> And unfortunately it's breaking the testsuite and not
|     Nathan> showing line numbers :-(
| 
|     Nathan> an example is g++.bugs/900121_01.C which now gives,
|     Nathan> 900121_01.C: In function `void function (s0 &, s0 &)':
|     Nathan> 900121_01.C:9: invalid use of a forward-declared, but not
|     Nathan> defined type `struct s0'
| 
|     Nathan> instead of the expected (and more useful)
| 
|     Nathan> 900121_01.C: In function `void function (s0 &, s0 &)':
|     Nathan> 900121_01.C:13: invalid use of undefined type `struct s0'
|     Nathan> 900121_01.C:9: forward declaration of `struct s0'
| 
|     Nathan> You've been a little too eager on combining diagnostics!
| 
| Youch.  Gaby, please review the places where you combined diagnostics
| to make sure that the line numbers haven't gotten munched.

Hmm... I restored the previous sequence calls, waiting for a less
contorsed solution.

In fact, the same pattern of sequence call is frequent in cp/*.c.
I think a solution will consist of letting cp_thing know about
the availability of the line-wrapping stuff in order to instruct the
line-wrapper to change prefix according to the '+' flag.  I am open to
alternatives.

For the time being, is the following patch ok to install?

-- Gaby

2000-01-19  Gabriel Dos Reis  <gdr@codesourcery.com>

	* typeck.c (build_unary_op): Use cp_pedwarn, not pedwarn.

	* typeck2.c (incomplete_type_error): Restore previous cp_error and
	cp_error_at call sequence.

Index: typeck.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/typeck.c,v
retrieving revision 1.237
diff -p -r1.237 typeck.c
*** typeck.c	2000/01/19 11:34:03	1.237
--- typeck.c	2000/01/19 18:31:08
*************** build_unary_op (code, xarg, noconvert)
*** 4701,4713 ****
  	      if (current_class_type
  		  && TREE_OPERAND (arg, 0) == current_class_ref)
  		/* An expression like &memfn.  */
! 		pedwarn ("ISO C++ forbids taking the address of a"
!                          " non-static member function to form a pointer"
!                          " to member function.  Say `&%T::%D'", base, name);
  	      else
! 		pedwarn ("ISO C++ forbids taking the address of a bound"
!                          " member function to form a pointer to member"
!                          " function", base, name);
  	    }
  
  	  arg = build_offset_ref (base, name);
--- 4701,4713 ----
  	      if (current_class_type
  		  && TREE_OPERAND (arg, 0) == current_class_ref)
  		/* An expression like &memfn.  */
! 		cp_pedwarn ("ISO C++ forbids taking the address of a"
!                             " non-static member function to form a pointer"
!                             " to member function.  Say `&%T::%D'", base, name);
  	      else
! 		cp_pedwarn ("ISO C++ forbids taking the address of a bound"
!                             " member function to form a pointer to member"
!                             " function", base, name);
  	    }
  
  	  arg = build_offset_ref (base, name);
Index: typeck2.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/typeck2.c,v
retrieving revision 1.71
diff -p -r1.71 typeck2.c
*** typeck2.c	2000/01/19 11:34:03	1.71
--- typeck2.c	2000/01/19 18:31:09
*************** retry:
*** 199,206 ****
      case RECORD_TYPE:
      case UNION_TYPE:
      case ENUMERAL_TYPE:
!       cp_error_at
!         ("invalid use of a forward-declared, but not defined type `%#T'", type);
        break;
  
      case VOID_TYPE:
--- 199,206 ----
      case RECORD_TYPE:
      case UNION_TYPE:
      case ENUMERAL_TYPE:
!       cp_error ("invalid use of undefined type `%#T'", type);
!       cp_error_at ("forward declaration of `%#T'", type);
        break;
  
      case VOID_TYPE:


More information about the Gcc-patches mailing list