]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/58083
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 18 Aug 2013 01:06:49 +0000 (01:06 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 18 Aug 2013 01:06:49 +0000 (01:06 +0000)
* name-lookup.c (push_class_level_binding_1): It's OK to push a
lambda type after the enclosing type is complete.

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

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

index 7ada1ae4f64244123723e66d568aaabb3ad67711..71dcfb8935fdf18f2c1652cc612d30ca80359bae 100644 (file)
@@ -1,3 +1,9 @@
+2013-08-17  Jason Merrill  <jason@redhat.com>
+
+       PR c++/58083
+       * name-lookup.c (push_class_level_binding_1): It's OK to push a
+       lambda type after the enclosing type is complete.
+
 2013-08-17  Gabriel Dos Reis  <gdr@integrable-solutions.net>
 
        * error.c (dump_scope): Add a cxx_pretty_printer parameter.
index 0fe0246913882a4b8d6073a3efd09d7faec94090..cf6c7573cedceda3076617ff1ce9f5cf3d2862fd 100644 (file)
@@ -3062,8 +3062,10 @@ push_class_level_binding_1 (tree name, tree x)
   if (name == error_mark_node)
     return false;
 
-  /* Check for invalid member names.  */
-  gcc_assert (TYPE_BEING_DEFINED (current_class_type));
+  /* Check for invalid member names.  But don't worry about a default
+     argument-scope lambda being pushed after the class is complete.  */
+  gcc_assert (TYPE_BEING_DEFINED (current_class_type)
+             || LAMBDA_TYPE_P (TREE_TYPE (decl)));
   /* Check that we're pushing into the right binding level.  */
   gcc_assert (current_class_type == class_binding_level->this_entity);
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg5.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg5.C
new file mode 100644 (file)
index 0000000..d85918d
--- /dev/null
@@ -0,0 +1,30 @@
+// PR c++/58083
+// { dg-do compile { target c++11 } }
+
+namespace details {
+struct iterator_concept_checker
+{
+    typedef char yes_type;
+    typedef char (&no_type)[2];
+
+    template <typename T>
+    static no_type test(...);
+
+    template <typename T>
+    static yes_type test(
+        int*
+       , void (*)(T) = [](T it)
+        {
+            auto copy = T{it};                              // copy constructible
+            copy = it;                                      // copy assignable
+            copy.~T();                                      // destroyable
+            ++it;                                           // incrementable
+        }
+      );
+};
+}
+
+int main()
+{
+  details::iterator_concept_checker::test<int>(0);
+}