re PR c++/53484 ([c++11] Wrong auto in lambdas in function templates)
authorJason Merrill <jason@redhat.com>
Fri, 1 Jun 2012 16:55:08 +0000 (12:55 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 1 Jun 2012 16:55:08 +0000 (12:55 -0400)
PR c++/53484
* pt.c (do_auto_deduction): Don't try to deduce from a
type-dependent initializer.

From-SVN: r188116

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

index 95e698d72ae4967fef1fc798356690023c45b9bf..62f18fad6b457635dc73ed7242a7ada41f4e7e03 100644 (file)
@@ -1,3 +1,9 @@
+2012-06-01  Jason Merrill  <jason@redhat.com>
+
+       PR c++/53484
+       * pt.c (do_auto_deduction): Don't try to deduce from a
+       type-dependent initializer.
+
 2012-06-01  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/26155
index c55687bb95fea9a85431bed520f45ee39e065f64..b58dd13672f2918e09e9ea922832b06eaab4b67e 100644 (file)
@@ -20318,10 +20318,9 @@ do_auto_deduction (tree type, tree init, tree auto_node)
   if (init == error_mark_node)
     return error_mark_node;
 
-  if (processing_template_decl
-      && (TREE_TYPE (init) == NULL_TREE
-         || BRACE_ENCLOSED_INITIALIZER_P (init)))
-    /* Not enough information to try this yet.  */
+  if (type_dependent_expression_p (init))
+    /* Defining a subset of type-dependent expressions that we can deduce
+       from ahead of time isn't worth the trouble.  */
     return type;
 
   /* [dcl.spec.auto]: Obtain P from T by replacing the occurrences of auto
index 28b853f598127e827f79c17ccfe7194570d29301..0c8a656c1330da1503d525901bee693722e32fce 100644 (file)
@@ -1,3 +1,8 @@
+2012-06-01  Jason Merrill  <jason@redhat.com>
+
+       PR c++/53484
+       * g++.dg/cpp0x/auto33.C: New.
+
 2012-06-01  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/26155
diff --git a/gcc/testsuite/g++.dg/cpp0x/auto33.C b/gcc/testsuite/g++.dg/cpp0x/auto33.C
new file mode 100644 (file)
index 0000000..dade5a8
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/53484
+// { dg-do compile { target c++11 } }
+
+template<class T,class U> struct ST;
+template<class T> struct ST<T,T> {};
+
+template <class T>
+void f(T x){
+   [&]{
+     auto y = x;
+     ST<decltype(y),int>();
+   }();
+}
+
+int main(){ f(0); }