OSDN Git Service

PR c++/50157
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 25 Aug 2011 18:22:46 +0000 (18:22 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 25 Aug 2011 18:22:46 +0000 (18:22 +0000)
* call.c (convert_like_real): Exit early if bad and !tf_error.

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

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

index 390a798..92363ff 100644 (file)
@@ -1,3 +1,8 @@
+2011-08-25  Jason Merrill  <jason@redhat.com>
+
+       PR c++/50157
+       * call.c (convert_like_real): Exit early if bad and !tf_error.
+
 2011-08-23  Jason Merrill  <jason@redhat.com>
 
        * typeck2.c (build_functional_cast): Don't try to avoid calling
index e5f65b3..d911b3a 100644 (file)
@@ -5642,6 +5642,9 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
   diagnostic_t diag_kind;
   int flags;
 
+  if (convs->bad_p && !(complain & tf_error))
+    return error_mark_node;
+
   if (convs->bad_p
       && convs->kind != ck_user
       && convs->kind != ck_list
@@ -5688,15 +5691,12 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
          else if (t->kind == ck_identity)
            break;
        }
-      if (complain & tf_error)
-       {
-         permerror (input_location, "invalid conversion from %qT to %qT", TREE_TYPE (expr), totype);
-         if (fn)
-           permerror (DECL_SOURCE_LOCATION (fn),
-                      "  initializing argument %P of %qD", argnum, fn);
-       }
-      else
-       return error_mark_node;
+
+      permerror (input_location, "invalid conversion from %qT to %qT",
+                TREE_TYPE (expr), totype);
+      if (fn)
+       permerror (DECL_SOURCE_LOCATION (fn),
+                  "  initializing argument %P of %qD", argnum, fn);
 
       return cp_convert (totype, expr);
     }
index c904def..c646612 100644 (file)
@@ -1,3 +1,8 @@
+2011-08-25  Jason Merrill  <jason@redhat.com>
+
+       PR c++/50157
+       * g++.dg/cpp0x/sfinae27.C: New.
+
 2011-08-25  Tobias Burnus  <burnus@net-b.de>
 
        * gfortran.dg/coarray_lib_token_4.f90: New.
diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae27.C b/gcc/testsuite/g++.dg/cpp0x/sfinae27.C
new file mode 100644 (file)
index 0000000..93327ba
--- /dev/null
@@ -0,0 +1,20 @@
+// PR c++/50157
+// { dg-options -std=c++0x }
+
+template<class T>
+T val();
+
+template<class T, class Arg, class =
+  decltype(::new T(val<Arg>()))
+>
+auto test(int) -> char;
+
+template<class, class>
+auto test(...) -> char (&)[2];
+
+struct P {
+  explicit operator bool(); // (#13)
+};
+
+typedef decltype(test<bool, P>(0)) type; // OK
+typedef decltype(test<float, P>(0)) type2; // Error (#17)