re PR c++/65075 (constexpr regression)
authorPaolo Carlini <paolo.carlini@oracle.com>
Tue, 17 Feb 2015 08:25:30 +0000 (08:25 +0000)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 17 Feb 2015 08:25:30 +0000 (09:25 +0100)
PR c++/65075
* constexpr.c (check_constexpr_bind_expr_vars): Allow
implicit typedefs for lambda types.

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

Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r220748

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

index 6d21c286686804b33c6afaab8c9d2153e88567b3..115a9f3700a4b54eb4dc24765a90f221c4ab33b5 100644 (file)
@@ -1,3 +1,10 @@
+2015-02-17  Paolo Carlini  <paolo.carlini@oracle.com>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/65075
+       * constexpr.c (check_constexpr_bind_expr_vars): Allow
+       implicit typedefs for lambda types.
+
 2015-02-13  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/60894
index d415dd4e6d27c41cb281a6450d2956edcc1c0b50..32a23ff738057bcb35e1147797509777367ebd11 100644 (file)
@@ -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;
 }
index ee133fa2bc052740ed67386242530dfc3511e403..ba21ab446bf3ac35c25029f2a136207c68639f61 100644 (file)
@@ -1,3 +1,9 @@
+2015-02-17  Paolo Carlini  <paolo.carlini@oracle.com>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/65075
+       * g++.dg/cpp0x/pr65075.C: New test.
+
 2015-02-16  David Edelsohn  <dje.gcc@gmail.com>
 
        PR target/65058
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr65075.C b/gcc/testsuite/g++.dg/cpp0x/pr65075.C
new file mode 100644 (file)
index 0000000..7d953ff
--- /dev/null
@@ -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)) ();
+}