public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ Patch] PR 22256
@ 2007-08-06 19:01 Paolo Carlini
  2007-08-09 22:40 ` Mark Mitchell
  0 siblings, 1 reply; 2+ messages in thread
From: Paolo Carlini @ 2007-08-06 19:01 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 477 bytes --]

Hi,

the problem here is that we try to be sophisticated and pedwarn instead
of plain error when the user specifies a return type consistent with the
conversion operator. Unfortunately the idea breaks as soon as pointers
or references are involved, because the type is "approximated" from
declspecs->type. AFAICS, we can simply error unconditionally (as other
front-ends already do) and obtain a consistent behavior.

Tested x86_64-linux, Ok?

Paolo.

////////////////////////

[-- Attachment #2: CL_22256 --]
[-- Type: text/plain, Size: 281 bytes --]

/cp
2007-08-06  Paolo Carlini  <pcarlini@suse.de>

	PR c++/22256
	* decl.c (check_special_function_return_type): Just error
	on return type specified for conversion operator.

/testsuite
2007-08-06  Paolo Carlini  <pcarlini@suse.de>

	PR c++/22256
	* g++.dg/conversion/op3.C: New.

[-- Attachment #3: patch_22256 --]
[-- Type: text/plain, Size: 1052 bytes --]

Index: testsuite/g++.dg/conversion/op3.C
===================================================================
*** testsuite/g++.dg/conversion/op3.C	(revision 0)
--- testsuite/g++.dg/conversion/op3.C	(revision 0)
***************
*** 0 ****
--- 1,3 ----
+ // PR c++/22256
+ 
+ struct node { int* operator int*(); }; // { dg-error "return type specified" }
Index: cp/decl.c
===================================================================
*** cp/decl.c	(revision 127238)
--- cp/decl.c	(working copy)
*************** check_special_function_return_type (spec
*** 6993,7002 ****
        break;
  
      case sfk_conversion:
!       if (type && !same_type_p (type, optype))
! 	error ("operator %qT declared to return %qT", optype, type);
!       else if (type)
! 	pedwarn ("return type specified for %<operator %T%>",  optype);
        type = optype;
        break;
  
--- 6993,7000 ----
        break;
  
      case sfk_conversion:
!       if (type)
! 	error ("return type specified for %<operator %T%>",  optype);
        type = optype;
        break;
  

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [C++ Patch] PR 22256
  2007-08-06 19:01 [C++ Patch] PR 22256 Paolo Carlini
@ 2007-08-09 22:40 ` Mark Mitchell
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Mitchell @ 2007-08-09 22:40 UTC (permalink / raw)
  To: Paolo Carlini; +Cc: gcc-patches

Paolo Carlini wrote:
> Hi,
> 
> the problem here is that we try to be sophisticated and pedwarn instead
> of plain error when the user specifies a return type consistent with the
> conversion operator. Unfortunately the idea breaks as soon as pointers
> or references are involved, because the type is "approximated" from
> declspecs->type. AFAICS, we can simply error unconditionally (as other
> front-ends already do) and obtain a consistent behavior.
> 
> Tested x86_64-linux, Ok?

OK.

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-08-09 22:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-06 19:01 [C++ Patch] PR 22256 Paolo Carlini
2007-08-09 22:40 ` Mark Mitchell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).