]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport fix for PRs c++/46824, c++/42260, c++/45383
authorDodji Seketeli <dodji@redhat.com>
Wed, 27 Apr 2011 12:07:34 +0000 (12:07 +0000)
committerDodji Seketeli <dodji@gcc.gnu.org>
Wed, 27 Apr 2011 12:07:34 +0000 (14:07 +0200)
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/cast2.C: New test.
* g++.dg/conversion/cast3.C: Likewise.
* g++.dg/conversion/cond4.C: Likewise.

From-SVN: r173025

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/cast3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/conversion/cond4.C [new file with mode: 0644]

index ac636d34538701f78013c827750bd7c021cc913e..3ee681503173b8f0ad1d2a94d28fa58429264d42 100644 (file)
@@ -1,3 +1,10 @@
+2011-04-26  Dodji Seketeli  <dodji@redhat.com>
+
+       PR c++/46824
+       * call.c (add_builtin_candidate)<case INDIRECT_REF>: The type of
+       the argument of the indirection operator should not be dependent.
+       Fix the comment.
+
 2011-04-26  Jason Merrill  <jason@redhat.com>
 
        PR c++/42687
index d4b7b050a33a02002a7919712403645764c9ecee..fce96b0eacf8080641ed14d2b44784cfa743a708 100644 (file)
@@ -1925,7 +1925,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*);
@@ -1936,6 +1936,7 @@ add_builtin_candidate (struct z_candidate **candidates, enum tree_code code,
 
     case INDIRECT_REF:
       if (TREE_CODE (type1) == POINTER_TYPE
+         && !uses_template_parms (TREE_TYPE (type1))
          && (TYPE_PTROB_P (type1)
              || TREE_CODE (TREE_TYPE (type1)) == FUNCTION_TYPE))
        break;
index 888ee603508250ff52b23fbe2b6ca6ca0a4c9af9..4d6f2f321d455b937ca397d3a7125acba1409cfe 100644 (file)
@@ -1,3 +1,10 @@
+2011-04-27  Dodji Seketeli  <dodji@redhat.com>
+
+       PR c++/46824, c++/42260, c++/45383
+       * g++.dg/conversion/cast2.C: New test.
+       * g++.dg/conversion/cast3.C: Likewise.
+       * g++.dg/conversion/cond4.C: Likewise.
+
 2011-04-26  Jason Merrill  <jason@redhat.com>
 
        * g++.dg/lookup/koenig13.C: New.
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..60af70d
--- /dev/null
@@ -0,0 +1,10 @@
+// Contributed by Dodji Seketeli <dodji@redhat.com>
+// 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/cast3.C b/gcc/testsuite/g++.dg/conversion/cast3.C
new file mode 100644 (file)
index 0000000..43287a1
--- /dev/null
@@ -0,0 +1,14 @@
+// Origin: PR c++/46824
+
+class Incomplete;
+struct Ptr
+{
+  operator Incomplete*();
+};
+
+int
+main()
+{
+  Ptr p;
+  *p;
+}
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;
+}