Hi,

this seems pretty straightforward given the grammar. Tested x86_64-linux.

Thanks,
Paolo.

////////////////////
/cp
2015-04-30  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/61683
        * parser.c (cp_parser_mem_initializer): Allow for decltype-specifier.

/testsuite
2015-04-30  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/61683
        * g++.dg/cpp0x/decltype-base1.C: New.
Index: cp/parser.c
===================================================================
--- cp/parser.c (revision 222599)
+++ cp/parser.c (working copy)
@@ -12776,6 +12776,7 @@ cp_parser_mem_initializer (cp_parser* parser)
 
    mem-initializer-id:
      :: [opt] nested-name-specifier [opt] class-name
+     decltype-specifier (C++11)
      identifier
 
    Returns a TYPE indicating the class to be initializer for the first
@@ -12838,14 +12839,18 @@ cp_parser_mem_initializer_id (cp_parser* parser)
                                 /*is_declaration=*/true);
   /* Otherwise, we could also be looking for an ordinary identifier.  */
   cp_parser_parse_tentatively (parser);
-  /* Try a class-name.  */
-  id = cp_parser_class_name (parser,
-                            /*typename_keyword_p=*/true,
-                            /*template_keyword_p=*/false,
-                            none_type,
-                            /*check_dependency_p=*/true,
-                            /*class_head_p=*/false,
-                            /*is_declaration=*/true);
+  if (cp_lexer_next_token_is_decltype (parser->lexer))
+    /* Try a decltype-specifier.  */
+    id = cp_parser_decltype (parser);
+  else
+    /* Otherwise, try a class-name.  */
+    id = cp_parser_class_name (parser,
+                              /*typename_keyword_p=*/true,
+                              /*template_keyword_p=*/false,
+                              none_type,
+                              /*check_dependency_p=*/true,
+                              /*class_head_p=*/false,
+                              /*is_declaration=*/true);
   /* If we found one, we're done.  */
   if (cp_parser_parse_definitely (parser))
     return id;
Index: testsuite/g++.dg/cpp0x/decltype-base1.C
===================================================================
--- testsuite/g++.dg/cpp0x/decltype-base1.C     (revision 0)
+++ testsuite/g++.dg/cpp0x/decltype-base1.C     (working copy)
@@ -0,0 +1,8 @@
+// PR c++/61683
+// { dg-do compile { target c++11 } }
+
+struct A {};
+A a;
+struct B : A {
+  B(): decltype(a)() {}
+};

Reply via email to