]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/52088
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 6 Feb 2012 19:52:43 +0000 (19:52 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 6 Feb 2012 19:52:43 +0000 (19:52 +0000)
* cvt.c (build_expr_type_conversion): Check for template conversion.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@183940 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/cvt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/conv13.C [new file with mode: 0644]

index 8938ee22cb86d1d5c4d99b757d74c16cf23ecf41..6cc274236136c368c1617042779129e072da7958 100644 (file)
@@ -1,3 +1,8 @@
+2012-02-06  Jason Merrill  <jason@redhat.com>
+
+       PR c++/52088
+       * cvt.c (build_expr_type_conversion): Check for template conversion.
+
 2012-01-31  Jason Merrill  <jason@redhat.com>
 
        PR c++/52043
index 8570e3d45028fd0a47e91521d21bc8a7bcb2b99a..c411a47f0a8f6960b59f92f431d42d208dea9042 100644 (file)
@@ -1539,6 +1539,17 @@ build_expr_type_conversion (int desires, tree expr, bool complain)
       if (DECL_NONCONVERTING_P (cand))
        continue;
 
+      if (TREE_CODE (cand) == TEMPLATE_DECL)
+       {
+         if (complain)
+           {
+             error ("ambiguous default type conversion from %qT",
+                    basetype);
+             error ("  candidate conversions include %qD", cand);
+           }
+         return error_mark_node;
+       }
+
       candidate = non_reference (TREE_TYPE (TREE_TYPE (cand)));
 
       switch (TREE_CODE (candidate))
index 305a689479561798ef07f94477bd753931968f63..186c5c9562e4072ad2a80024168adb173592847a 100644 (file)
@@ -1,3 +1,8 @@
+2012-02-06  Jason Merrill  <jason@redhat.com>
+
+       PR c++/52088
+       * g++.dg/template/conv13.C: New.
+
 2012-02-06  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/52115
diff --git a/gcc/testsuite/g++.dg/template/conv13.C b/gcc/testsuite/g++.dg/template/conv13.C
new file mode 100644 (file)
index 0000000..717994b
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/52088
+
+struct S
+{
+  template <typename T>
+  operator T *() { return 0; }
+};
+
+int main()
+{
+  S s;
+  delete s;                   // { dg-error "ambiguous|template|pointer" }
+}