re PR c++/87093 (is_constructible (__is_constructible() instrinsic) explicitly instan...
authorVille Voutilainen <ville.voutilainen@gmail.com>
Wed, 12 Sep 2018 21:10:43 +0000 (00:10 +0300)
committerVille Voutilainen <ville@gcc.gnu.org>
Wed, 12 Sep 2018 21:10:43 +0000 (00:10 +0300)
PR c++/87093

gcc/cp

PR c++/87093
* method.c (constructible_expr): We're in an unevaluated context
in all cases, not just for class targets.

testsuite/

PR c++/87093
* g++.dg/ext/is_constructible2.C: New.

From-SVN: r264253

gcc/cp/ChangeLog
gcc/cp/method.c
gcc/testsuite/g++.dg/ext/is_constructible2.C [new file with mode: 0644]

index 9201d67c0ab79022adcaf6c1bbb2bb7b127ffd4b..ca8939d9a087489277c6711cdf0c98431192c117 100644 (file)
@@ -1,3 +1,9 @@
+2018-09-13  Ville Voutilainen  <ville.voutilainen@gmail.com>
+
+       PR c++/87093
+       * method.c (constructible_expr): We're in an unevaluated context
+       in all cases, not just for class targets.
+
 2018-09-12  David Malcolm  <dmalcolm@redhat.com>
 
        PR c++/85110
index 0b208a8d52a519f40609e4fb1ba258d4a750e589..d75dacb1373d7f8e35b5e264cfdc0d83a304703c 100644 (file)
@@ -1144,11 +1144,11 @@ static tree
 constructible_expr (tree to, tree from)
 {
   tree expr;
+  cp_unevaluated cp_uneval_guard;
   if (CLASS_TYPE_P (to))
     {
       tree ctype = to;
       vec<tree, va_gc> *args = NULL;
-      cp_unevaluated cp_uneval_guard;
       if (!TYPE_REF_P (to))
        to = cp_build_reference_type (to, /*rval*/false);
       tree ob = build_stub_object (to);
diff --git a/gcc/testsuite/g++.dg/ext/is_constructible2.C b/gcc/testsuite/g++.dg/ext/is_constructible2.C
new file mode 100644 (file)
index 0000000..8f25e7e
--- /dev/null
@@ -0,0 +1,12 @@
+// { dg-do compile { target c++11 } }
+
+#include <type_traits>
+
+template <typename T> struct x {
+  operator bool() {
+    static_assert(!std::is_same<T, T>::value, "");
+    return false;
+  }
+};
+
+static constexpr auto a = __is_constructible(bool, x<int>);