{"id":2225518,"url":"http://patchwork.ozlabs.org/api/patches/2225518/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/aecXWG8aqJfdhcDI@tucnak/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<aecXWG8aqJfdhcDI@tucnak>","list_archive_url":null,"date":"2026-04-21T06:21:12","name":"c++: Parse splice-type-specifier in cp_parser_mem_initializer_id [PR124944]","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"ad6dfd0a2db92e69197da42601cba48d5f88c016","submitter":{"id":671,"url":"http://patchwork.ozlabs.org/api/people/671/?format=json","name":"Jakub Jelinek","email":"jakub@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/aecXWG8aqJfdhcDI@tucnak/mbox/","series":[{"id":500740,"url":"http://patchwork.ozlabs.org/api/series/500740/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=500740","date":"2026-04-21T06:21:12","name":"c++: Parse splice-type-specifier in cp_parser_mem_initializer_id [PR124944]","version":1,"mbox":"http://patchwork.ozlabs.org/series/500740/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2225518/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2225518/checks/","tags":{},"related":[],"headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=abErREeT;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (1024-bit key,\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=abErREeT","sourceware.org; dmarc=pass (p=quarantine dis=none)\n header.from=redhat.com","sourceware.org; spf=pass smtp.mailfrom=redhat.com","server2.sourceware.org;\n arc=none smtp.remote-ip=170.10.129.124"],"Received":["from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g0C1S3VHBz1yGt\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 21 Apr 2026 16:21:48 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 809A24BA23EB\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 21 Apr 2026 06:21:46 +0000 (GMT)","from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.129.124])\n by sourceware.org (Postfix) with ESMTP id 549744BA9000\n for <gcc-patches@gcc.gnu.org>; Tue, 21 Apr 2026 06:21:19 +0000 (GMT)","from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-141-JmwN6ObvMl-ZOgyqq15F5A-1; Tue,\n 21 Apr 2026 02:21:17 -0400","from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id B9EA919560A2\n for <gcc-patches@gcc.gnu.org>; Tue, 21 Apr 2026 06:21:16 +0000 (UTC)","from tucnak.zalov.cz (unknown [10.44.48.12])\n by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with\n ESMTPS\n id 05FC71800352; Tue, 21 Apr 2026 06:21:15 +0000 (UTC)","from tucnak.zalov.cz (localhost [127.0.0.1])\n by tucnak.zalov.cz (8.18.1/8.18.1) with ESMTPS id 63L6LDe1886247\n (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT);\n Tue, 21 Apr 2026 08:21:13 +0200","(from jakub@localhost)\n by tucnak.zalov.cz (8.18.1/8.18.1/Submit) id 63L6LDiA886246;\n Tue, 21 Apr 2026 08:21:13 +0200"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 809A24BA23EB","OpenDKIM Filter v2.11.0 sourceware.org 549744BA9000"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 549744BA9000","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 549744BA9000","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776752479; cv=none;\n b=WJlSmodvfcR0ADTaAV0FW1SSqT+RaCjMh4H4LyNEQ4f4uyxh+qQfXgpvVK7FJYSOZjdlha+jwhRz1BqzBgHE91NqFHlskFd7JI+t79RCcv31F8a9T9Dic9+nXQv2ewmGlsKLHqg1SBQuQt1ApXTBoBDTWz2cR+774/5iP4dRcy0=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776752479; c=relaxed/simple;\n bh=gvhIZGGB9jQPNyE6VeGh1ovkRQaTFrzRAOQ6eyUd1HE=;\n h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version;\n b=XCNkaUxkVll0SI/r7WVkH8QrCYtTrBQdVCMEX/TMVfxCb83L1R6pTuZY10Ty1whp9xc9gruNzoe+WSMMHONj97dIMRR04iOJn5rrIyRoUp6vtnioDF6o6uGs4kOhplcQurboEUYCWZIrK638Qv3Nyl+N+SV5J72/Tm/3M6aqqSc=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1776752479;\n h=from:from:reply-to:reply-to:subject:subject:date:date:\n message-id:message-id:to:to:cc:cc:mime-version:mime-version:\n content-type:content-type; bh=kqbd7hFWZu2Z6jgxMweNFrcLyyKw6GFgHb4yG46uL/s=;\n b=abErREeTKv77dQFuykQz4tkKJIqCL64jaFhxMDII/95HPCuz/A3MJpNmr9KOQ44OsuQeU1\n oS6a2cTEjNeBBiUAbKYIvw064+LDg+b7li7lSyxx5AygM+yJzD3st7JyOudmoi4EqzLvt+\n j/2V8DIXxsmomBZsJ3EsX0F9xbfx9Tg=","X-MC-Unique":"JmwN6ObvMl-ZOgyqq15F5A-1","X-Mimecast-MFC-AGG-ID":"JmwN6ObvMl-ZOgyqq15F5A_1776752477","Date":"Tue, 21 Apr 2026 08:21:12 +0200","From":"Jakub Jelinek <jakub@redhat.com>","To":"Jason Merrill <jason@redhat.com>, Marek Polacek <polacek@redhat.com>","Cc":"gcc-patches@gcc.gnu.org","Subject":"[PATCH] c++: Parse splice-type-specifier in\n cp_parser_mem_initializer_id [PR124944]","Message-ID":"<aecXWG8aqJfdhcDI@tucnak>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.4.1 on 10.30.177.111","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"bWaaLoWD4Ul1udc-n_VCg7WTrhicKodCDBhEzRHfMfU_1776752477","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Reply-To":"Jakub Jelinek <jakub@redhat.com>","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"},"content":"Hi!\n\nThe grammar has:\nmem-initializer-id:\n\tclass-or-decltype\n\tidentifier\nclass-or-decltype:\n\tnested-name-specifier[opt] type-name\n\tnested-name-specifier template simple-template-id\n\tcomputed-type-specifier\ncomputed-type-specifier:\n\tdecltype-specifier\n\tpack-index-specifier\n\tsplice-type-specifier\nbut we weren't parsing splice-type-specifier in there, just in\ncp_parser_base_specifier.  So, the following patch defers\nsimilarly to cp_parser_base_specifier the typename diagnostics\nbecause we don't know whether typename [: will be valid or not\n- it could be splice-scope-specifier and in that case typename\nis not valid, or splice-type-specifier, in which case it is valid\nbut not required.  And calls cp_parser_splice_type_specifier too\nwhen nested-name-specifier nor :: don't appear.\n\nBootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?\n\n2026-04-21  Jakub Jelinek  <jakub@redhat.com>\n\n\tPR c++/124944\n\t* parser.cc (cp_parser_mem_initializer_id): Parse\n\tsplice-type-specifier.\n\n\t* g++.dg/reflect/splice13.C: New test.\n\t* g++.dg/reflect/splice14.C: New test.\n\n\n\tJakub","diff":"--- gcc/cp/parser.cc.jj\t2026-04-16 18:56:51.665066851 +0200\n+++ gcc/cp/parser.cc\t2026-04-20 20:14:17.454246322 +0200\n@@ -19974,14 +19974,17 @@ cp_parser_mem_initializer_id (cp_parser*\n   bool template_p = false;\n   tree id;\n \n-  cp_token *token = cp_lexer_peek_token (parser->lexer);\n+  cp_token *typename_token = nullptr, *splice_token = nullptr;\n \n-  /* `typename' is not allowed in this context ([temp.res]).  */\n+  /* `typename' is not allowed in this context ([temp.res]), unless\n+      it is part of splice-type-specifier.  Defer diagnostics for now\n+      because it needs to be diagnosed if followed by splice-scope-specifier\n+      but not when followed by splice-type-specifier.  */\n   if (cp_lexer_next_token_is_keyword (parser->lexer, RID_TYPENAME))\n     {\n-      error_at (token->location,\n-\t\t\"keyword %<typename%> not allowed in this context (a qualified \"\n-\t\t\"member initializer is implicitly a type)\");\n+      typename_token = cp_lexer_peek_token (parser->lexer);\n+      if (cp_parser_next_tokens_start_splice_type_spec_p (parser, true))\n+\tsplice_token = cp_lexer_peek_nth_token (parser->lexer, 2);\n       cp_lexer_consume_token (parser->lexer);\n     }\n   /* Look for the optional `::' operator.  */\n@@ -20008,6 +20011,12 @@ cp_parser_mem_initializer_id (cp_parser*\n \t\t\t\t\t    /*type_p=*/true,\n \t\t\t\t\t    /*is_declaration=*/true)\n        != NULL_TREE);\n+  if (typename_token && cp_lexer_peek_token (parser->lexer) != splice_token)\n+    /* Emit deferred diagnostics for invalid typename keyword if\n+       cp_parser_nested_name_specifier_opt parsed splice-scope-specifier.  */\n+    error_at (typename_token->location,\n+\t      \"keyword %<typename%> not allowed in this context (a qualified \"\n+\t      \"member initializer is implicitly a type)\");\n   if (nested_name_specifier_p)\n     template_p = cp_parser_optional_template_keyword (parser);\n   /* If there is a `::' operator or a nested-name-specifier, then we\n@@ -20020,6 +20029,14 @@ cp_parser_mem_initializer_id (cp_parser*\n \t\t\t\t /*check_dependency_p=*/true,\n \t\t\t\t /*class_head_p=*/false,\n \t\t\t\t /*is_declaration=*/true);\n+  else if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_SPLICE))\n+    {\n+      /* Parse C++26 splice-type-specifier.  */\n+      id = cp_parser_splice_type_specifier (parser);\n+      if (id == NULL_TREE)\n+\treturn error_mark_node;\n+      return id;\n+    }\n   /* Otherwise, we could also be looking for an ordinary identifier.  */\n   cp_parser_parse_tentatively (parser);\n   if (cp_lexer_next_token_is_decltype (parser->lexer))\n--- gcc/testsuite/g++.dg/reflect/splice13.C.jj\t2026-04-20 20:17:23.199120525 +0200\n+++ gcc/testsuite/g++.dg/reflect/splice13.C\t2026-04-20 20:16:47.095728081 +0200\n@@ -0,0 +1,23 @@\n+// PR c++/124944\n+// { dg-do compile { target c++26 } }\n+// { dg-additional-options \"-freflection\" }\n+\n+struct A {};\n+constexpr auto x = ^^A;\n+\n+struct B : [: x :] {\n+  B () : typename [: x :] () {}\n+};\n+\n+struct C : [: x :] {\n+  C () : [: x :] () {}\n+};\n+\n+namespace D {\n+  struct E {};\n+}\n+constexpr auto y = ^^D;\n+\n+struct F : [: y :]::E {\n+  F () : [: y :]::E () {}\n+};\n--- gcc/testsuite/g++.dg/reflect/splice14.C.jj\t2026-04-20 20:17:30.732993744 +0200\n+++ gcc/testsuite/g++.dg/reflect/splice14.C\t2026-04-20 20:20:51.386617097 +0200\n@@ -0,0 +1,12 @@\n+// PR c++/124944\n+// { dg-do compile { target c++26 } }\n+// { dg-additional-options \"-freflection\" }\n+\n+namespace D {\n+  struct E {};\n+}\n+constexpr auto y = ^^D;\n+\n+struct F : [: y :]::E {\n+  F () : typename [: y :]::E () {}\t// { dg-error \"keyword 'typename' not allowed in this context \\\\\\(a qualified member initializer is implicitly a type\\\\\\)\" }\n+};\n","prefixes":[]}