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]

Re: (C++) call.c patch


>>>>> "Eric" == Eric Christopher <echristo@cygnus.com> writes:

I don't think you've sent this one to gcc-patches yet, so I've taken
the liberty of passing it on.

> This one has a testcase of:

> #include <cstdio>

> struct A {
>   A() {}
>   ~A() {}
> };

> const A a;
> int main()
> {
>   a.A::~A();
> }

> And the error message is:

> t.cc: In function `int main ()':
> t.cc:17: passing `const A' as `this' argument of `A::~A ()' 

> This appears to be valid code and the patch below makes the symptoms
> look correct with no regressions.

> Is it correct?

It's correct, but I'd prefer to fix this bug in the code that handles
destructors, namely build_delete.  There already seems to be code
there that tries to strip cv-quals from the object.

> Index: call.c
> ===================================================================
> RCS file: /cvs/cvsfiles/devo/gcc/cp/call.c,v
> retrieving revision 1.353
> diff -u -p -w -r1.353 call.c
> --- call.c	2000/06/01 19:07:41	1.353
> +++ call.c	2000/11/03 00:39:45
> @@ -3969,7 +3969,7 @@ build_over_call (cand, args, flags)
>        tree parmtype = TREE_VALUE (parm);
>        tree argtype = TREE_TYPE (TREE_VALUE (arg));
>        tree t;
> -      if (ICS_BAD_FLAG (TREE_VEC_ELT (convs, i)))
> +      if (ICS_BAD_FLAG (TREE_VEC_ELT (convs, i)) && !DECL_DESTRUCTOR_P (fn))
>  	cp_pedwarn ("passing `%T' as `this' argument of `%#D' discards qualifiers",
>  		    TREE_TYPE (argtype), fn);
 

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