From d37c775a73d38dd63ede24a26970d162c72fa963 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 1 Jun 2012 12:55:08 -0400 Subject: [PATCH] re PR c++/53484 ([c++11] Wrong auto in lambdas in function templates) PR c++/53484 * pt.c (do_auto_deduction): Don't try to deduce from a type-dependent initializer. From-SVN: r188116 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 7 +++---- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/auto33.C | 15 +++++++++++++++ 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/auto33.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 95e698d72ae..62f18fad6b4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2012-06-01 Jason Merrill + + PR c++/53484 + * pt.c (do_auto_deduction): Don't try to deduce from a + type-dependent initializer. + 2012-06-01 Paolo Carlini PR c++/26155 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index c55687bb95f..b58dd13672f 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 28b853f5981..0c8a656c133 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-06-01 Jason Merrill + + PR c++/53484 + * g++.dg/cpp0x/auto33.C: New. + 2012-06-01 Paolo Carlini 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 index 00000000000..dade5a8ba25 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto33.C @@ -0,0 +1,15 @@ +// PR c++/53484 +// { dg-do compile { target c++11 } } + +template struct ST; +template struct ST {}; + +template +void f(T x){ + [&]{ + auto y = x; + ST(); + }(); +} + +int main(){ f(0); } -- 2.30.2