public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR c++/46824
@ 2011-03-11 16:49 Dodji Seketeli
  2011-03-11 17:08 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Dodji Seketeli @ 2011-03-11 16:49 UTC (permalink / raw)
  To: Jason Merrill; +Cc: GCC Patches

Hello,

In my fix for PR c++/42260 I wanted to exclude conversion operators
that return dependent types from the candidates functions during
overload resolution in cases like:

    struct A
    {
	  template<typename T> operator T*();
    };

    int i = *A();

During the overload resolution to determine the conversions that would
convert A into a non-class type, we don't want the conversion function
template to be part of the candidates.

I requested the target type of the conversion to be complete and that
was too strong and is not causing the code in the example of the patch
below to be rejected.

I believe Just requesting it to be non-dependent should be enough.

Meanwhile, this comment in the code:

    For every cv-qualified or cv-unqualified complete object type T,
    there exist candidate operator functions of the form

		 T&      operator*(T*);

is not correct (anymore?).  In [over.built]/6 it reads:

    For every cv-qualified or cv-unqualified object type T, there exist
    candidate operator functions of the form

	T&     operator*(T *);

Apparently in 1996 the type was required to be complete in the code
and the comment but that changed since then.

So I removed the "complete" from the comment.  I wish I had double
checked that in the spec earlier :-(

Here is the patch I am currently testing against trunk.

-- 
		Dodji

From 9d9f38e1ef36a6ae1240f72834ed6657e382dc0e Mon Sep 17 00:00:00 2001
From: Dodji Seketeli <dodji@redhat.com>
Date: Fri, 11 Mar 2011 17:13:16 +0100
Subject: [PATCH] PR c++/46824

gcc/cp/

	* call.c (add_builtin_candidate)<case INDIRECT_REF>: The type
	of the argument of the indirection operator should not be
	dependent.  Fix the comment.

gcc/testsuite/

	* g++.dg/conversion/cast3.C: New test.
---
 gcc/cp/call.c                           |    4 ++--
 gcc/testsuite/g++.dg/conversion/cast3.C |   14 ++++++++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/conversion/cast3.C

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index a297f53..5953e35 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -2150,7 +2150,7 @@ add_builtin_candidate (struct z_candidate **candidates, enum tree_code code,
 	}
       return;
 
-/* 7 For every cv-qualified or cv-unqualified complete object type T, there
+/* 7 For every cv-qualified or cv-unqualified object type T, there
      exist candidate operator functions of the form
 
 	     T&      operator*(T*);
@@ -2161,7 +2161,7 @@ add_builtin_candidate (struct z_candidate **candidates, enum tree_code code,
 
     case INDIRECT_REF:
       if (TREE_CODE (type1) == POINTER_TYPE
-	  && is_complete (TREE_TYPE (type1))
+	  && !uses_template_parms (TREE_TYPE (type1))
 	  && (TYPE_PTROB_P (type1)
 	      || TREE_CODE (TREE_TYPE (type1)) == FUNCTION_TYPE))
 	break;
diff --git a/gcc/testsuite/g++.dg/conversion/cast3.C b/gcc/testsuite/g++.dg/conversion/cast3.C
new file mode 100644
index 0000000..43287a1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/conversion/cast3.C
@@ -0,0 +1,14 @@
+// Origin: PR c++/46824
+
+class Incomplete;
+struct Ptr
+{
+  operator Incomplete*();
+};
+
+int
+main()
+{
+  Ptr p;
+  *p;
+}
-- 
1.7.3.4

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

* Re: [PATCH] PR c++/46824
  2011-03-11 16:49 [PATCH] PR c++/46824 Dodji Seketeli
@ 2011-03-11 17:08 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2011-03-11 17:08 UTC (permalink / raw)
  To: GCC Patches

OK.

Jason

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

end of thread, other threads:[~2011-03-11 17:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-11 16:49 [PATCH] PR c++/46824 Dodji Seketeli
2011-03-11 17:08 ` Jason Merrill

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).