/cp
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 25 Nov 2011 01:00:44 +0000 (01:00 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 25 Nov 2011 01:00:44 +0000 (01:00 +0000)
2011-11-24  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/51227
* pt.c (instantiate_class_template_1): If lambda_function (type)
is NULL_TREE do not instantiate_decl.

/testsuite
2011-11-24  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/51227
* g++.dg/cpp0x/lambda/lambda-ice5.C: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181707 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 83a5508..0772ee9 100644 (file)
@@ -1,5 +1,11 @@
 2011-11-24  Paolo Carlini  <paolo.carlini@oracle.com>
 
+       PR c++/51227
+       * pt.c (instantiate_class_template_1): If lambda_function (type)
+       is NULL_TREE do not instantiate_decl.
+
+2011-11-24  Paolo Carlini  <paolo.carlini@oracle.com>
+
        PR c++/51290
        * class.c (build_base_path): For the null pointer check use
        nullptr_node instead of integer_zero_node.
index f817b6f..4725080 100644 (file)
@@ -9103,14 +9103,20 @@ instantiate_class_template_1 (tree type)
 
   if (CLASSTYPE_LAMBDA_EXPR (type))
     {
-      tree lambda = CLASSTYPE_LAMBDA_EXPR (type);
-      if (LAMBDA_EXPR_DEDUCE_RETURN_TYPE_P (lambda))
+      tree decl = lambda_function (type);
+      if (decl)
        {
-         apply_lambda_return_type (lambda, void_type_node);
-         LAMBDA_EXPR_RETURN_TYPE (lambda) = NULL_TREE;
+         tree lambda = CLASSTYPE_LAMBDA_EXPR (type);
+         if (LAMBDA_EXPR_DEDUCE_RETURN_TYPE_P (lambda))
+           {
+             apply_lambda_return_type (lambda, void_type_node);
+             LAMBDA_EXPR_RETURN_TYPE (lambda) = NULL_TREE;
+           }
+         instantiate_decl (decl, false, false);
+         maybe_add_lambda_conv_op (type);
        }
-      instantiate_decl (lambda_function (type), false, false);
-      maybe_add_lambda_conv_op (type);
+      else
+       gcc_assert (errorcount);
     }
 
   /* Set the file and line number information to whatever is given for
index e162c0b..229e6d8 100644 (file)
@@ -1,3 +1,8 @@
+2011-11-24  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/51227
+       * g++.dg/cpp0x/lambda/lambda-ice5.C: New.
+
 2011-11-24  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR target/51134
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice5.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice5.C
new file mode 100644 (file)
index 0000000..305db81
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/51227
+// { dg-options "-std=c++0x" }
+
+template<int> int foo()
+{
+  [] (void i) { return 0; } (0); // { dg-error "incomplete|invalid|no match" }
+}
+
+void bar()
+{
+  foo<0>();
+}