public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Paolo Carlini <paolo.carlini@oracle.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Cc: Jason Merrill <jason@redhat.com>
Subject: [C++ Patch] PR 61683
Date: Thu, 30 Apr 2015 00:56:00 -0000	[thread overview]
Message-ID: <55416FC5.3010906@oracle.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 117 bytes --]

Hi,

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

Thanks,
Paolo.

////////////////////

[-- Attachment #2: CL_61683 --]
[-- Type: text/plain, Size: 264 bytes --]

/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.

[-- Attachment #3: patch_61683 --]
[-- Type: text/plain, Size: 1823 bytes --]

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	other threads:[~2015-04-29 23:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-30  0:56 Paolo Carlini [this message]
2015-05-11 15:57 ` [Ping] " Paolo Carlini
2015-05-22  7:54 ` Paolo Carlini
2015-05-25 19:56   ` Jason Merrill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55416FC5.3010906@oracle.com \
    --to=paolo.carlini@oracle.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).