OSDN Git Service

PR c++/50863
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 7 Nov 2011 22:52:32 +0000 (22:52 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 7 Nov 2011 22:52:32 +0000 (22:52 +0000)
* parser.c (cp_parser_initializer_list): Parse C99
array designators tentatively.

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

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

index 4945fd9..92025a9 100644 (file)
@@ -1,5 +1,9 @@
 2011-11-07  Jason Merrill  <jason@redhat.com>
 
+       PR c++/50863
+       * parser.c (cp_parser_initializer_list): Parse C99
+       array designators tentatively.
+
        PR c++/50870
        * pt.c (tsubst_copy): Handle NAMESPACE_DECL.
        (tsubst_copy_and_build) [COMPONENT_REF]: Handle a still-dependent
index fa0117e..697be80 100644 (file)
@@ -17580,10 +17580,13 @@ cp_parser_initializer_list (cp_parser* parser, bool* non_constant_p)
               && !c_dialect_objc ()
               && cp_lexer_next_token_is (parser->lexer, CPP_OPEN_SQUARE))
        {
+         /* In C++11, [ could start a lambda-introducer.  */
+         cp_parser_parse_tentatively (parser);
          cp_lexer_consume_token (parser->lexer);
          designator = cp_parser_constant_expression (parser, false, NULL);
          cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE);
          cp_parser_require (parser, CPP_EQ, RT_EQ);
+         cp_parser_parse_definitely (parser);
        }
       else
        designator = NULL_TREE;
index e2eccc5..c5f4118 100644 (file)
@@ -1,5 +1,8 @@
 2011-11-07  Jason Merrill  <jason@redhat.com>
 
+       PR c++/50863
+       * g++.dg/cpp0x/lambda/lambda-initlist1.C: New.
+
        PR c++/50870
        * g++.dg/cpp0x/decltype35.C: New.
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-initlist1.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-initlist1.C
new file mode 100644 (file)
index 0000000..078ebae
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/50863
+// { dg-options -std=gnu++0x }
+
+struct T {
+  template<typename F>
+  T(F) { }
+};
+
+int main()
+{
+  T t{ []{ } };
+}