Hi!

If there are lambdas in C++11 constexpr return-stmts, we get implicit
typedefs of the lambda types, but those are artificial and we should ignore
them.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2015-02-16  Paolo Carlini  <paolo.carl...@oracle.com>
            Jakub Jelinek  <ja...@redhat.com>

        PR c++/65075
        * constexpr.c (check_constexpr_bind_expr_vars): Allow
        implicit typedefs for lambda types.

        * g++.dg/cpp0x/pr65075.C: New test.

--- gcc/cp/constexpr.c.jj       2015-02-14 00:19:49.000000000 +0100
+++ gcc/cp/constexpr.c  2015-02-16 15:12:06.260262857 +0100
@@ -416,7 +416,8 @@ check_constexpr_bind_expr_vars (tree t)
 
   for (tree var = BIND_EXPR_VARS (t); var; var = DECL_CHAIN (var))
     if (TREE_CODE (var) == TYPE_DECL
-       && DECL_IMPLICIT_TYPEDEF_P (var))
+       && DECL_IMPLICIT_TYPEDEF_P (var)
+       && !LAMBDA_TYPE_P (TREE_TYPE (var)))
       return false;
   return true;
 }
--- gcc/testsuite/g++.dg/cpp0x/pr65075.C.jj     2015-02-16 15:09:48.405517062 
+0100
+++ gcc/testsuite/g++.dg/cpp0x/pr65075.C        2015-02-16 15:09:23.000000000 
+0100
@@ -0,0 +1,17 @@
+// PR c++/65075
+// { dg-do compile { target c++11 } }
+
+typedef void (*E) ();
+template <class T>
+constexpr E
+bar (bool a)
+{
+  return a ? []() {} : []() {};
+}
+
+void
+foo ()
+{
+  (bar<int> (false)) ();
+  (bar<int> (true)) ();
+}

        Jakub

Reply via email to