diff mbox

[C++] PR 61683

Message ID 55416FC5.3010906@oracle.com
State New
Headers show

Commit Message

Paolo Carlini April 29, 2015, 11:56 p.m. UTC
Hi,

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

Thanks,
Paolo.

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

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

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

	PR c++/61683
	* g++.dg/cpp0x/decltype-base1.C: New.

Comments

Paolo Carlini May 11, 2015, 3:57 p.m. UTC | #1
Hi,

pinging this...

On 04/30/2015 01:56 AM, Paolo Carlini wrote:
> Hi,
>
> this seems pretty straightforward given the grammar. Tested x86_64-linux.

     https://gcc.gnu.org/ml/gcc-patches/2015-04/msg01948.html

Paolo.
Paolo Carlini May 22, 2015, 7:14 a.m. UTC | #2
Hi,

On 04/30/2015 01:56 AM, Paolo Carlini wrote:
> Hi,
>
> this seems pretty straightforward given the grammar. Tested x86_64-linux.
... again, given the grammar, I think this is even obvious: if nobody 
screams, I'm going to commit the patch in a day or so (but I'm naming 
the testcase decltype-mem-initializer1.C instead, seems more correct to me)

Thanks!
Paolo.
Jason Merrill May 25, 2015, 7:44 p.m. UTC | #3
OK, thanks.

Jason
diff mbox

Patch

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)() {}
+};