Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.1/patches/2233270/?format=api
{ "id": 2233270, "url": "http://patchwork.ozlabs.org/api/1.1/patches/2233270/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/20260506011912.1371228-1-polacek@redhat.com/", "project": { "id": 17, "url": "http://patchwork.ozlabs.org/api/1.1/projects/17/?format=api", "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 }, "msgid": "<20260506011912.1371228-1-polacek@redhat.com>", "date": "2026-05-06T01:19:12", "name": "c++: deferred parsing of default arguments [PR50479]", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "4d06c2702dd9f91412deed84e970791de913a40c", "submitter": { "id": 14370, "url": "http://patchwork.ozlabs.org/api/1.1/people/14370/?format=api", "name": "Marek Polacek", "email": "polacek@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/20260506011912.1371228-1-polacek@redhat.com/mbox/", "series": [ { "id": 502915, "url": "http://patchwork.ozlabs.org/api/1.1/series/502915/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=502915", "date": "2026-05-06T01:19:12", "name": "c++: deferred parsing of default arguments [PR50479]", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/502915/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2233270/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2233270/checks/", "tags": {}, "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=VhAWiG4t;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=38.145.34.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=VhAWiG4t", "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 [38.145.34.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 4g9HcM5hTXz1yJq\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 06 May 2026 11:20:02 +1000 (AEST)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 4DD3E4BA9036\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 6 May 2026 01:20:00 +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 97A5C4BA23F5\n for <gcc-patches@gcc.gnu.org>; Wed, 6 May 2026 01:19:20 +0000 (GMT)", "from mx-prod-mc-03.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-553-AIcw75LIO5CYw7lCriodvw-1; Tue,\n 05 May 2026 21:19:18 -0400", "from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4])\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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id AD1661956053\n for <gcc-patches@gcc.gnu.org>; Wed, 6 May 2026 01:19:17 +0000 (UTC)", "from pdp-11.redhat.com (unknown [10.22.81.22])\n by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id 1F7BA30001A1; Wed, 6 May 2026 01:19:17 +0000 (UTC)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 4DD3E4BA9036", "OpenDKIM Filter v2.11.0 sourceware.org 97A5C4BA23F5" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 97A5C4BA23F5", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 97A5C4BA23F5", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778030360; cv=none;\n b=OJOUmyb8/0RELOIG/uwBNEEjpCtFkvNJHyIkM5J/r3vpFTP7+jESTOErcoHg4oRYWmmOicJ/IC5jnZiSkedMElwSjyHWRVRUgWQkd1fdpjVFK6l1rpHWLSBviSQny67qGUFR9QekAjXTMkvhGnTjWggVzCFqcF44XqhFUvGILBc=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1778030360; c=relaxed/simple;\n bh=WCk2dqq7kK/DIFEthSRNAxPabQXTbxGTctKaHr4X67s=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=BLuG0vo6FHu/Y/NV2cnwWdLWTnh7wQjXSOF0h2tHrxoiw7WqwLEhsb4KL/4prS2VhkQauQIGMVd7VU2TFc1JBtjBsYFoooUpQ6cr3zXP1Pg1GK5yxjLHpP3Edrf/bS24+xiFBirm4KiwVwmMgaYqlrsf6vD+BuulB3/QOe2/piU=", "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=1778030360;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding;\n bh=EPG/zQhe1lfC7d+M1xZ5qCL0t0UhMjAPZC9foaPuiNo=;\n b=VhAWiG4t0HelhiskhPhptvNmqoyzMlGO+CHKc280Irdb+tereFueZXbRodzex58otHyyVp\n qMH5L6l16tohTSe+ZV0L4djvZkCetyx/S5M2F/5+24qkQ2BoAGEe6AqxAR+b/PFzAPhF/4\n EBpuPUeKtiPVC0EQcqTRwLYmve5+9Vc=", "X-MC-Unique": "AIcw75LIO5CYw7lCriodvw-1", "X-Mimecast-MFC-AGG-ID": "AIcw75LIO5CYw7lCriodvw_1778030357", "From": "Marek Polacek <polacek@redhat.com>", "To": "Jason Merrill <jason@redhat.com>,\n\tGCC Patches <gcc-patches@gcc.gnu.org>", "Subject": "[PATCH] c++: deferred parsing of default arguments [PR50479]", "Date": "Tue, 5 May 2026 21:19:12 -0400", "Message-ID": "<20260506011912.1371228-1-polacek@redhat.com>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 3.4.1 on 10.30.177.4", "X-Mimecast-Spam-Score": "0", "X-Mimecast-MFC-PROC-ID": "OjmOCcptWXe-72tO1W32k6bo5b3p0136D0TkgZ7XrRI_1778030357", "X-Mimecast-Originator": "redhat.com", "Content-Transfer-Encoding": "8bit", "content-type": "text/plain; charset=\"US-ASCII\"; x-default=true", "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>", "Errors-To": "gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org" }, "content": "Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?\n\nAdditionally tested with the \"Optimization only\" checks disabled\nto see if it isn't hiding any errors.\n\n-- >8 --\nIn\n\n void fn (int i = sizeof (i)) {}\n\nthe i in sizeof should refer to the parameter ([basic.scope.pdecl]) and\nsince the second i is not evaluated, the code is valid per\n[dcl.fct.default]/9: A parameter shall not appear as a potentially\nevaluated expression in a default argument.\n\nTo make this work, we have to defer parsing of the default argument\nuntil we've done grokdeclarator + pushdecl on i. Unfortunately,\nlambdas complicated this patch somewhat. _late_parse_one_default_arg\nalways does start_lambda_scope which here would set lambda_scope.scope\nto the parameter which doesn't yet have a DECL_CONTEXT, and we'd crash.\nBut for the default argument in\n\n inline void g(int n) {\n int bef(int i = []{ return 1; }());\n }\n\nthe scope should be 'g' anyway, not 'bef'. Thus the adjust_lambda_scope_p\nparameter to preserve the existing behavior.\n\n\tPR c++/50479\n\tPR c++/62244\n\ngcc/cp/ChangeLog:\n\n\t* parser.cc (defining_nonlambda_class_type_p): New.\n\t(cp_parser_parameter_declaration_list): Maybe perform deferred\n\tparsing of default arguments.\n\t(cp_parser_parameter_declaration): Defer parsing of named\n\tparameters.\n\t(cp_parser_noexcept_specification_opt): Use\n\tdefining_nonlambda_class_type_p.\n\t(cp_parser_late_parse_one_default_arg): New parameter. Use it to\n\tavoid the calls to start_/finish_lambda_scope.\n\ngcc/testsuite/ChangeLog:\n\n\t* g++.dg/reflect/parm1.C: Uncomment code.\n\t* g++.dg/parse/defarg22.C: New test.\n\t* g++.dg/parse/defarg23.C: New test.\n\t* g++.dg/parse/defarg24.C: New test.\n\t* g++.dg/parse/defarg25.C: New test.\n\t* g++.dg/parse/defarg26.C: New test.\n---\n gcc/cp/parser.cc | 86 +++++++++++++++++++++------\n gcc/testsuite/g++.dg/parse/defarg22.C | 16 +++++\n gcc/testsuite/g++.dg/parse/defarg23.C | 36 +++++++++++\n gcc/testsuite/g++.dg/parse/defarg24.C | 12 ++++\n gcc/testsuite/g++.dg/parse/defarg25.C | 22 +++++++\n gcc/testsuite/g++.dg/parse/defarg26.C | 18 ++++++\n gcc/testsuite/g++.dg/reflect/parm1.C | 5 +-\n 7 files changed, 173 insertions(+), 22 deletions(-)\n create mode 100644 gcc/testsuite/g++.dg/parse/defarg22.C\n create mode 100644 gcc/testsuite/g++.dg/parse/defarg23.C\n create mode 100644 gcc/testsuite/g++.dg/parse/defarg24.C\n create mode 100644 gcc/testsuite/g++.dg/parse/defarg25.C\n create mode 100644 gcc/testsuite/g++.dg/parse/defarg26.C\n\n\nbase-commit: 3a9643ffe7fea815aab8afa122a4bf12fbc5b54e", "diff": "diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc\nindex d128de771b5..9c8cd7bdc90 100644\n--- a/gcc/cp/parser.cc\n+++ b/gcc/cp/parser.cc\n@@ -3104,7 +3104,7 @@ static void cp_parser_save_default_args\n static void cp_parser_late_parsing_for_member\n (cp_parser *, tree);\n static tree cp_parser_late_parse_one_default_arg\n- (cp_parser *, tree, tree, tree);\n+ (cp_parser *, tree, tree, tree, bool = true);\n static void cp_parser_late_parsing_nsdmi\n (cp_parser *, tree);\n static void cp_parser_late_parsing_default_args\n@@ -28126,6 +28126,17 @@ function_being_declared_is_template_p (cp_parser* parser)\n \t (current_class_type));\n }\n \n+/* Return true if we are defining a class which is not a lambda closure\n+ type. */\n+\n+static bool\n+defining_nonlambda_class_type_p ()\n+{\n+ return (at_class_scope_p ()\n+\t && TYPE_BEING_DEFINED (current_class_type)\n+\t && !LAMBDA_TYPE_P (current_class_type));\n+}\n+\n /* Parse a parameter-declaration-clause.\n \n parameter-declaration-clause:\n@@ -28370,6 +28381,32 @@ cp_parser_parameter_declaration_list (cp_parser* parser,\n \t retrofit_lang_decl (decl);\n \t DECL_PARM_INDEX (decl) = ++index;\n \t DECL_PARM_LEVEL (decl) = function_parm_depth ();\n+\n+\t if (tree &def = parameter->default_argument)\n+\t if (TREE_CODE (def) == DEFERRED_PARSE\n+\t\t/* If we're defining a class, let _class_specifier\n+\t\t -> _late_parsing_default_args re-parse the default\n+\t\t argument. */\n+\t\t&& !defining_nonlambda_class_type_p ())\n+\t {\n+\t\tauto lvf\n+\t\t = make_temp_override (parser->local_variables_forbidden_p);\n+\t\tparser->local_variables_forbidden_p\n+\t\t = LOCAL_VARS_AND_THIS_FORBIDDEN;\n+\t\tpush_unparsed_function_queues (parser);\n+\t\t/* We used to not defer parsing for default arguments outside\n+\t\t classes, and just called _default_argument. In order to\n+\t\t preserve mangling of lambdas (see e.g. in lambda-mangle.C),\n+\t\t we tell this function to omit the call to start_lambda_scope\n+\t\t otherwise the lambda scope would be the current PARM_DECL\n+\t\t which doesn't have a context yet. Even if it had a context,\n+\t\t it would be wrong for block-extern function declarations\n+\t\t where the context should be the enclosing function body. */\n+\t\tdef = cp_parser_late_parse_one_default_arg (parser, decl, def,\n+\t\t\t\t\t\t\t TREE_TYPE (decl),\n+\t\t\t\t\t\t\t /*lscope=*/false);\n+\t\tpop_unparsed_function_queues (parser);\n+\t }\n \t}\n \n /* Add the new parameter to the list. */\n@@ -28710,21 +28747,30 @@ cp_parser_parameter_declaration (cp_parser *parser,\n eq_token = token;\n if (declarator)\n \tdeclarator->init_loc = token->location;\n- /* If we are defining a class, then the tokens that make up the\n-\t default argument must be saved and processed later. */\n- if (!template_parm_p && at_class_scope_p ()\n-\t && TYPE_BEING_DEFINED (current_class_type)\n-\t && !LAMBDA_TYPE_P (current_class_type))\n-\tdefault_argument = cp_parser_cache_defarg (parser, /*nsdmi=*/false);\n-\n /* A constrained-type-specifier may declare a type\n \t template-parameter. */\n- else if (declares_constrained_type_template_parameter (type))\n+ if (declares_constrained_type_template_parameter (type))\n default_argument\n = cp_parser_default_type_template_argument (parser);\n-\n- /* Outside of a class definition, we can just parse the\n-\t assignment-expression. */\n+ /* If we are defining a class, then the tokens that make up the\n+\t default argument must be saved and processed later. We also\n+\t have to defer parsing for named parameters to correctly handle\n+\t void fn (int i = sizeof (i));\n+\t which is OK. */\n+ else if (!template_parm_p\n+\t && (defining_nonlambda_class_type_p ()\n+\t\t || (get_id_declarator (declarator)\n+\t\t /* Optimization only: if we see \"int i = 42\",\n+\t\t\t we don't have to defer parsing. */\n+\t\t && !((cp_lexer_nth_token_is (parser->lexer, 2,\n+\t\t\t\t\t\t CPP_NUMBER)\n+\t\t\t || cp_lexer_nth_token_is (parser->lexer, 2,\n+\t\t\t\t\t\t CPP_KEYWORD))\n+\t\t\t && (cp_lexer_nth_token_is (parser->lexer, 3,\n+\t\t\t\t\t\t CPP_CLOSE_PAREN)\n+\t\t\t\t|| cp_lexer_nth_token_is (parser->lexer, 3,\n+\t\t\t\t\t\t\t CPP_COMMA))))))\n+\tdefault_argument = cp_parser_cache_defarg (parser, /*nsdmi=*/false);\n else\n \tdefault_argument\n \t = cp_parser_default_argument (parser, template_parm_p);\n@@ -32177,9 +32223,7 @@ cp_parser_noexcept_specification_opt (cp_parser* parser,\n \t && !((cp_lexer_nth_token_is (parser->lexer, 3, CPP_NUMBER)\n \t\t|| cp_lexer_nth_token_is (parser->lexer, 3, CPP_KEYWORD))\n \t && cp_lexer_nth_token_is (parser->lexer, 4, CPP_CLOSE_PAREN))\n-\t && at_class_scope_p ()\n-\t && TYPE_BEING_DEFINED (current_class_type)\n-\t && !LAMBDA_TYPE_P (current_class_type))\n+\t && defining_nonlambda_class_type_p ())\n \treturn cp_parser_save_noexcept (parser);\n \n cp_lexer_consume_token (parser->lexer);\n@@ -37088,11 +37132,13 @@ cp_parser_save_default_args (cp_parser* parser, tree decl)\n /* DEFAULT_ARG contains the saved tokens for the initializer of DECL,\n which is either a FIELD_DECL or PARM_DECL. Parse it and return\n the result. For a PARM_DECL, PARMTYPE is the corresponding type\n- from the parameter-type-list. */\n+ from the parameter-type-list. If adjust_lambda_scope_p is true,\n+ we do start_/finish_lambda_scope. */\n \n static tree\n cp_parser_late_parse_one_default_arg (cp_parser *parser, tree decl,\n-\t\t\t\t tree default_arg, tree parmtype)\n+\t\t\t\t tree default_arg, tree parmtype,\n+\t\t\t\t bool adjust_lambda_scope_p/*=true*/)\n {\n cp_token_cache *tokens;\n tree parsed_arg;\n@@ -37105,14 +37151,16 @@ cp_parser_late_parse_one_default_arg (cp_parser *parser, tree decl,\n tokens = DEFPARSE_TOKENS (default_arg);\n cp_parser_push_lexer_for_tokens (parser, tokens);\n \n- start_lambda_scope (decl);\n+ if (adjust_lambda_scope_p)\n+ start_lambda_scope (decl);\n \n /* Parse the default argument. */\n parsed_arg = cp_parser_initializer (parser);\n if (BRACE_ENCLOSED_INITIALIZER_P (parsed_arg))\n maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);\n \n- finish_lambda_scope ();\n+ if (adjust_lambda_scope_p)\n+ finish_lambda_scope ();\n \n if (parsed_arg == error_mark_node)\n cp_parser_skip_to_end_of_statement (parser);\ndiff --git a/gcc/testsuite/g++.dg/parse/defarg22.C b/gcc/testsuite/g++.dg/parse/defarg22.C\nnew file mode 100644\nindex 00000000000..f393b95a591\n--- /dev/null\n+++ b/gcc/testsuite/g++.dg/parse/defarg22.C\n@@ -0,0 +1,16 @@\n+// PR c++/50479\n+// { dg-do compile }\n+\n+void fn1 (int i = sizeof (i)) {}\n+void fn2 (int i, int = sizeof (i)) {}\n+\n+void\n+g ()\n+{\n+ void fn4 (int i = sizeof (i));\n+ void fn5 (int i, int = sizeof (i));\n+ fn1 ();\n+ fn2 (42);\n+ fn4 ();\n+ fn5 (42);\n+}\ndiff --git a/gcc/testsuite/g++.dg/parse/defarg23.C b/gcc/testsuite/g++.dg/parse/defarg23.C\nnew file mode 100644\nindex 00000000000..0aeb1b33394\n--- /dev/null\n+++ b/gcc/testsuite/g++.dg/parse/defarg23.C\n@@ -0,0 +1,36 @@\n+// PR c++/50479\n+// { dg-do compile { target c++14 } }\n+\n+inline void\n+fn1 ()\n+{\n+ int f (int i = []{ return 1; }());\n+}\n+\n+auto l = [](int i = sizeof (i)) { };\n+void fn2 (int i = []{ return 1; }()) {}\n+void fn3 (int x = []{ decltype(x) y{}; return y; }()) {}\n+void fn6 (int i = sizeof (i), decltype (i) = sizeof (i)) {}\n+\n+struct S {\n+ int mfn1 (int i = sizeof (i)) { return i; }\n+ int mfn2 (int i, int = sizeof (i)) { return i; }\n+ int lm = [](int i6 = sizeof (i6)) { return i6; }();\n+ int mfn3 (int i = []{ return 1; }()) { return i; }\n+ int i = mfn1 () + mfn2 (42) + mfn3 () + lm;\n+};\n+\n+void\n+g ()\n+{\n+ auto ll = [](int i5 = sizeof (i5)) { };\n+ void fn4 (int i = []{ return 1; }());\n+ void fn5 (int x = []{ decltype(x) y{}; return y; }());\n+ fn1 ();\n+ fn2 ();\n+ fn3 ();\n+ fn4 ();\n+ fn5 ();\n+ fn6 ();\n+ l ();\n+}\ndiff --git a/gcc/testsuite/g++.dg/parse/defarg24.C b/gcc/testsuite/g++.dg/parse/defarg24.C\nnew file mode 100644\nindex 00000000000..48b6f1f2a1c\n--- /dev/null\n+++ b/gcc/testsuite/g++.dg/parse/defarg24.C\n@@ -0,0 +1,12 @@\n+// PR c++/50479\n+// { dg-do compile { target c++11 } }\n+\n+void fn1 (int x = []{ return x; }()) {}\t // { dg-error \"use of parameter outside function body\" }\n+void fn2 (int x, int = []{ return x; }()) {} // { dg-error \"use of parameter outside function body\" }\n+\n+void\n+g ()\n+{\n+ void fn3 (int z = []{ return z; }());\t // { dg-error \"use of parameter outside function body\" }\n+ void fn4 (int z, int = []{ return z; }()); // { dg-error \"use of parameter outside function body\" }\n+}\ndiff --git a/gcc/testsuite/g++.dg/parse/defarg25.C b/gcc/testsuite/g++.dg/parse/defarg25.C\nnew file mode 100644\nindex 00000000000..95989885dfa\n--- /dev/null\n+++ b/gcc/testsuite/g++.dg/parse/defarg25.C\n@@ -0,0 +1,22 @@\n+// PR c++/62244\n+// { dg-do compile { target c++11 } }\n+\n+int a;\n+void f (int a = a); // { dg-error \"parameter .a. may not appear in this context\" }\n+\n+int foo(int x = (decltype(x)(42))) { return 0; }\n+\n+static int value;\n+\n+int\n+bar (int &value = value) // { dg-error \"parameter .value. may not appear in this context\" }\n+{\n+ return value;\n+}\n+\n+void\n+g ()\n+{\n+ bar ();\n+}\n+\ndiff --git a/gcc/testsuite/g++.dg/parse/defarg26.C b/gcc/testsuite/g++.dg/parse/defarg26.C\nnew file mode 100644\nindex 00000000000..170f7f5c0ec\n--- /dev/null\n+++ b/gcc/testsuite/g++.dg/parse/defarg26.C\n@@ -0,0 +1,18 @@\n+// PR c++/50479\n+// { dg-do compile { target c++11 } }\n+\n+template<class>\n+struct A;\n+\n+template<>\n+struct A<long> {\n+ static const int value = 1;\n+};\n+\n+long foo;\n+\n+void bar(char foo = A<decltype(foo)>::value) {} // { dg-error \"incomplete type\" }\n+\n+int main() {\n+ bar();\n+}\ndiff --git a/gcc/testsuite/g++.dg/reflect/parm1.C b/gcc/testsuite/g++.dg/reflect/parm1.C\nindex 8416be5b0db..c844c1dff3f 100644\n--- a/gcc/testsuite/g++.dg/reflect/parm1.C\n+++ b/gcc/testsuite/g++.dg/reflect/parm1.C\n@@ -4,9 +4,8 @@\n \n #include <meta>\n \n-// FIXME PR62244\n-//consteval int fn(decltype(^^::) x = ^^x) { return 0; }\n-//constexpr int x = fn ();\n+consteval int fn(decltype(^^::) x = ^^x) { return 0; }\n+constexpr int x = fn ();\n \n consteval auto\n ref (std::meta::info r)\n", "prefixes": [] }