Fix PR c++/42260 and ensure PR c++/45383 is fixed
authorDodji Seketeli <dodji@redhat.com>
Mon, 29 Nov 2010 16:31:40 +0000 (16:31 +0000)
committerDodji Seketeli <dodji@gcc.gnu.org>
Mon, 29 Nov 2010 16:31:40 +0000 (17:31 +0100)
gcc/cp/
c++/42260
* call.c (add_builtin_candidate): At this point the resulting type
of an indirection operator should be complete.

gcc/testsuite/
c++/42260
c++/45383
* g++.dg/conversion/cast2.C: New test.
* g++.dg/conversion/cond4/C: Likewise. Ensures we don't regress on
PR c++/45383

From-SVN: r167250

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/conversion/cast2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/conversion/cond4.C [new file with mode: 0644]

index feb9620bdcd7583ea37cd1d0dfd7ffbed074e9b9..40dd7e299e92bfffc5ffc471614d8a3a04b95e40 100644 (file)
@@ -1,3 +1,9 @@
+2010-11-29  Dodji Seketeli  <dodji@redhat.com>
+
+       PR c++/42260
+       * call.c (add_builtin_candidate): At this point the resulting type
+       of an indirection operator should be complete.
+
 2010-11-29  Dodji Seketeli  <dodji@redhat.com>
 
        PR c++/45383
index d107a71747e6a7ef2fd60a32738c117c696d7145..0f016ca324a6573a509ddd6bcf4fd33dbecff53e 100644 (file)
@@ -2022,6 +2022,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))
          && (TYPE_PTROB_P (type1)
              || TREE_CODE (TREE_TYPE (type1)) == FUNCTION_TYPE))
        break;
index a1ebffbbaeb67684412cead89866da301318e99a..1cfb5b2dfe6b3ee57d6189126d8468c42997b7b0 100644 (file)
@@ -1,3 +1,10 @@
+2010-11-29  Dodji Seketeli  <dodji@redhat.com>
+
+       PR c++/42260
+       * g++.dg/conversion/cast2.C: New test.
+       * g++.dg/conversion/cond4/C: Likewise. This ensures we don't regress on
+       PR c++/45383
+
 2010-11-29  Dodji Seketeli  <dodji@redhat.com>
 
        PR c++/45383
diff --git a/gcc/testsuite/g++.dg/conversion/cast2.C b/gcc/testsuite/g++.dg/conversion/cast2.C
new file mode 100644 (file)
index 0000000..ac83297
--- /dev/null
@@ -0,0 +1,9 @@
+// Origin: PR c++/42260
+// { dg-do compile }
+
+struct A
+{
+      template<typename T> operator T*();
+};
+
+int i = *A();// { dg-error "no match" }
diff --git a/gcc/testsuite/g++.dg/conversion/cond4.C b/gcc/testsuite/g++.dg/conversion/cond4.C
new file mode 100644 (file)
index 0000000..3bd6476
--- /dev/null
@@ -0,0 +1,31 @@
+// Origin: PR c++/45383
+// { dg-do run }
+
+struct null {
+    null() {}
+    template<class T>
+    operator T*() const {
+    return 0;
+    }
+
+    template<class C, class T>
+    operator T C::*() const {
+    return 0;
+    }
+private:
+    null(const null&);
+    null& operator=(const null&);
+    void operator&() const;
+};
+
+static struct null null;
+
+int
+main()
+{
+    int* ptr = null;
+    if (ptr == null)
+        return 0;
+    if (ptr != null)
+        return 1;
+}