re PR c++/47687 ([C++0x] Crash on a lambda returning a lambda (using std::function))
authorJason Merrill <jason@redhat.com>
Fri, 27 May 2011 19:32:07 +0000 (15:32 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 27 May 2011 19:32:07 +0000 (15:32 -0400)
PR c++/47687
* pt.c (dependent_type_p_r): Avoid infinite recursion.

From-SVN: r174354

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

index 19ef7caec271018f2e76a192e6f64e35ec1403b3..edc14219e61cafafe0394964f2b86991498d31c3 100644 (file)
@@ -1,5 +1,8 @@
 2011-05-27  Jason Merrill  <jason@redhat.com>
 
+       PR c++/47687
+       * pt.c (dependent_type_p_r): Avoid infinite recursion.
+
        PR c++/48284
        * error.c (dump_expr) [COMPONENT_REF]: Use pp_cxx_dot
        with INDIRECT_REF of REFERENCE_TYPE.
index 71fe0a0f1e1b3a8029378eeb07cbd50256a47245..ae3d83da39db5f38aa44d4746d1c4080850275ce 100644 (file)
@@ -18260,8 +18260,15 @@ dependent_type_p_r (tree type)
   scope = TYPE_CONTEXT (type);
   if (scope && TYPE_P (scope))
     return dependent_type_p (scope);
-  else if (scope && TREE_CODE (scope) == FUNCTION_DECL)
-    return type_dependent_expression_p (scope);
+  /* Don't use type_dependent_expression_p here, as it can lead
+     to infinite recursion trying to determine whether a lambda
+     nested in a lambda is dependent (c++/47687).  */
+  else if (scope && TREE_CODE (scope) == FUNCTION_DECL
+          && DECL_LANG_SPECIFIC (scope)
+          && DECL_TEMPLATE_INFO (scope)
+          && (any_dependent_template_arguments_p
+              (INNERMOST_TEMPLATE_ARGS (DECL_TI_ARGS (scope)))))
+    return true;
 
   /* Other types are non-dependent.  */
   return false;
index d034def5f3f70fe37e6fe49e6f05e9fbd9e9b1f8..841a2023d882033e25215ad1433544d7c64408d6 100644 (file)
@@ -1,5 +1,7 @@
 2011-05-27  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/cpp0x/lambda/lambda-nested4.C: New.
+
        * g++.dg/cpp0x/error6.C: New.
 
        * g++.dg/cpp0x/error5.C: New.
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested4.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested4.C
new file mode 100644 (file)
index 0000000..a5bd1a2
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/47687
+// { dg-options -std=c++0x }
+
+template <class T> struct A { };
+
+auto inl = []{ return []{}; }();
+typedef decltype(inl) inlt;
+
+A<inlt> a;