Gentle ping with rebased patch.
вс, 11 окт. 2026 г. в 23:08, Vladislav Semykin <[email protected] >: > gcc-verify and gcc-style green. > > All the 3588 tests from: > > dg.exp=cpp0x/pr125886.C > dg.exp=coroutines/unevaluated.C > dg.exp=rtti/*.C > dg.exp=cpp0x/constexpr-typeid*.C > dg.exp=cpp2a/constexpr-typeid*.C > dg.exp=template/typeid*.C > dg.exp=cpp0x/lambda/*.C > dg.exp=cpp1y/*lambda*.C > dg.exp=cpp2a/*lambda*.C > > are green. >
From ba11ad1b49a08205304f047c16c0283c31dfe6e7 Mon Sep 17 00:00:00 2001 From: Vladislav Semykin <[email protected]> Date: Sun, 11 Oct 2026 22:58:47 +0300 Subject: [PATCH v1] c++: do not let a typeid probe consume a lambda [PR c++/127750] To: [email protected] A polymorphic glvalue operand of typeid is potentially evaluated ([expr.typeid]/4). The front end still parses that operand once under cp_unevaluated, then rolls the lexer back and parses it again. Lambda discriminators are function-scope counters, not lexer state, so the probe consumes a discriminator and the closure that remains mangles as UlvE0_ where GCC 16 mangled UlvE_. The same probe makes cp_parser_lambda_expression reject the lambda before C++20, returns error_mark_node, and skips the evaluated reparse. save_lambda_discriminators snapshots lambda_scope and every stacked slot, including the signature counts. The evaluated reparse restores that snapshot and marks the probe closure TREE_ASM_WRITTEN, dropping its call operator from the symbol table, so the two parses do not emit the same mangled name. A probe that is the real parse discards the snapshot and keeps the increments. The pre-C++20 diagnostic is deferred only while cp_unevaluated_operand equals cp_unevaluated_typeid_cutoff. A deeper unevaluated operand, such as sizeof inside the probe, still errors immediately. A dependent operand is diagnosed from the template pattern in tsubst_expr. The missing std::bad_typeid for a null glvalue of a final polymorphic type, and the model that treats such a glvalue as an unevaluated operand, are separate bugs. This patch does not change resolves_to_fixed_type_p or build_typeid. Environment: | Item | Value | | --------------------- | ------------------------------------------------------------------------------------------------------------------------- | | OS | Ubuntu 24.04.5 LTS, kernel 7.0.0-38-generic | | CPU | 12th Gen Intel Core i9-12900H (20 logical cores) | | Source | `/home/loveit0/Develop/gcc` at `4d75e994d68` | | Build tree | `/home/loveit0/Develop/gcc-build` | | Prefix | `/home/loveit0/gcc-dev` | | Configure | `--enable-bootstrap --disable-multilib --enable-languages=c,c++,lto` | | Build / Host / Target | `x86_64-pc-linux-gnu` (all three; read from `gcc-build/config.status`) | | Bootstrap compiler | gcc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0 | | Compiler under test | `xg++ (GCC) 17.0.0 20261011 (experimental)` in `gcc-build/gcc/` | | Rebuild of this patch | From `/home/loveit0/Develop/gcc-build`: `make -j$(nproc) bootstrap` of the patched tree, then the 2026-10-11 22:49 sweep. | Testing: from /home/loveit0/Develop/gcc-build, bootstrapped the patched tree with "make -j$(nproc) bootstrap" (--enable-bootstrap --disable-multilib, x86_64-pc-linux-gnu). No check-c++-all. Then make check-c++ with the sweep dg.exp=cpp0x/pr125886.C dg.exp=coroutines/unevaluated.C dg.exp=rtti/*.C dg.exp=cpp0x/constexpr-typeid*.C dg.exp=cpp2a/constexpr-typeid*.C dg.exp=template/typeid*.C dg.exp=cpp0x/lambda/*.C dg.exp=cpp1y/*lambda*.C dg.exp=cpp2a/*lambda*.C was run on 2026-10-11 (xg++ 17.0.0 20261011). The eight sweeps other than rtti/ matched the pre-patch counts (6, 12, 6 passes / 3 expected failures, 23, 9, 1598 / 18 expected failures / 6 unsupported, 793, 833 / 10 expected failures / 4 unsupported). dg.exp=rtti/*.C was 308 expected passes and 3 unsupported. Pre-patch that directory was 279 expected passes and 3 unsupported. No FAIL, XPASS, or UNRESOLVED. Total expected passes: 3588. contrib/check_GNU_style.py on the uncommitted diff is clean. git gcc-verify was not run; there is no commit yet. PR c++/127750 gcc/cp/ChangeLog: PR c++/127750 * cp-tree.h (save_lambda_discriminators, restore_lambda_discriminators, discard_lambda_discriminators, error_lambda_in_unevaluated_context, reject_unevaluated_typeid_lambdas): Declare. * lambda.cc (save_lambda_discriminators, restore_lambda_discriminators, discard_lambda_discriminators, error_lambda_in_unevaluated_context, reject_unevaluated_typeid_lambdas): New. (record_lambda_scope_discriminator, record_lambda_scope_sig_discriminator): Note a lambda recorded during a typeid probe. * parser.cc (cp_parser_postfix_expression): Snapshot lambda discriminators around the typeid probe and restore them when the operand is reparsed evaluated. (cp_parser_lambda_expression): Defer the pre-C++20 unevaluated lambda diagnostic for that probe. * pt.cc (tsubst_expr): Likewise for TYPEID_EXPR, and reject a lambda kept in an unevaluated operand before C++20. gcc/testsuite/ChangeLog: PR c++/127750 * g++.dg/rtti/typeid-lambda-disc-pr127750.C: New test. * g++.dg/rtti/typeid-lambda-uneval-pr127750.C: New test. Signed-off-by: Vladislav Semykin <[email protected]> --- gcc/cp/cp-tree.h | 5 + gcc/cp/lambda.cc | 224 ++++++++++++++++++ gcc/cp/parser.cc | 64 +++-- gcc/cp/pt.cc | 26 +- .../g++.dg/rtti/typeid-lambda-disc-pr127750.C | 43 ++++ .../rtti/typeid-lambda-uneval-pr127750.C | 59 +++++ 6 files changed, 401 insertions(+), 20 deletions(-) create mode 100644 gcc/testsuite/g++.dg/rtti/typeid-lambda-disc-pr127750.C create mode 100644 gcc/testsuite/g++.dg/rtti/typeid-lambda-uneval-pr127750.C diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 8c6d0ea3744..175ac27a0ce 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -8741,6 +8741,11 @@ extern void finish_lambda_scope (void); extern void record_lambda_scope (tree lambda); extern void record_lambda_scope_discriminator (tree lambda); extern void record_lambda_scope_sig_discriminator (tree lambda, tree fn); +extern void *save_lambda_discriminators (void); +extern void restore_lambda_discriminators (void *); +extern void discard_lambda_discriminators (void *); +extern void error_lambda_in_unevaluated_context (location_t); +extern tree reject_unevaluated_typeid_lambdas (tree, tsubst_flags_t); extern tree start_lambda_function (tree fn, tree lambda_expr); extern void push_capture_proxies (tree, bool = false); extern void finish_lambda_function (tree body); diff --git a/gcc/cp/lambda.cc b/gcc/cp/lambda.cc index 5677c6e6e66..134b533c090 100644 --- a/gcc/cp/lambda.cc +++ b/gcc/cp/lambda.cc @@ -1769,6 +1769,228 @@ compare_lambda_sig (tree fn_a, tree fn_b) return true; } +/* Saved discriminator slot. The signature vector is GC-allocated; + the copy is on the heap so a collection during the probe cannot + drop it. */ + +struct lambda_sig_snap +{ + tree fn; + unsigned count; +}; + +struct lambda_scope_snap +{ + tree scope; + unsigned nesting; + unsigned count; + auto_vec<lambda_sig_snap> sigs; +}; + +/* One unevaluated typeid probe. Nested probes stack. LAMBDAS are + the closures recorded while this probe was current. Restoring the + counters does not by itself stop those closures from being emitted, + so restore marks them written and drops them from the symbol table + (PR c++/127750). */ + +struct lambda_disc_checkpoint +{ + lambda_scope_snap live; + auto_vec<lambda_scope_snap *> stack; + auto_vec<tree> lambdas; + lambda_disc_checkpoint *outer; + + ~lambda_disc_checkpoint () + { + for (unsigned i = 0; i < stack.length (); ++i) + delete stack[i]; + } +}; + +static lambda_disc_checkpoint *lambda_disc_current; + +/* Copy IN into OUT. */ + +static void +snapshot_lambda_scope (lambda_scope_snap &out, + const lambda_discriminator &in) +{ + out.scope = in.scope; + out.nesting = in.nesting; + out.count = in.count; + out.sigs.truncate (0); + unsigned n = vec_safe_length (in.discriminators); + for (unsigned i = 0; i < n; ++i) + { + const lambda_sig_count &src = (*in.discriminators)[i]; + lambda_sig_snap snap; + snap.fn = src.fn; + snap.count = src.count; + out.sigs.safe_push (snap); + } +} + +/* Put SAVED back into SLOT. The live signature vector is abandoned. + It may have grown during the probe, and freeing a va_gc vector from + here is not safe. */ + +static void +restore_lambda_scope_slot (lambda_discriminator &slot, + const lambda_scope_snap &saved) +{ + slot.scope = saved.scope; + slot.nesting = saved.nesting; + slot.count = saved.count; + slot.discriminators = nullptr; + for (unsigned i = 0; i < saved.sigs.length (); ++i) + { + lambda_sig_count sig; + sig.fn = saved.sigs[i].fn; + sig.count = saved.sigs[i].count; + vec_safe_push (slot.discriminators, sig); + } +} + +/* Remember a closure recorded while a typeid probe is current. + Both recorders see the same lambda; keep it once. */ + +static void +note_speculative_lambda (tree lambda) +{ + if (!lambda_disc_current || lambda == error_mark_node) + return; + auto ¬ed = lambda_disc_current->lambdas; + if (!noted.is_empty () && noted.last () == lambda) + return; + noted.safe_push (lambda); +} + +/* The probe built this closure and then threw that parse away. The + surviving re-parse reuses its discriminator, so this copy must not + be emitted. */ + +static void +suppress_speculative_lambda (tree lambda) +{ + tree closure = LAMBDA_EXPR_CLOSURE (lambda); + if (!closure || !LAMBDA_TYPE_P (closure)) + return; + /* The call operator is the symbol whose mangled name repeats the + discriminator. The closure may not have it yet if the probe + failed before the declarator. */ + tree fn = lambda_function (closure); + if (fn && TREE_CODE (fn) == TEMPLATE_DECL) + { + TREE_ASM_WRITTEN (fn) = 1; + fn = DECL_TEMPLATE_RESULT (fn); + } + if (!fn || TREE_CODE (fn) != FUNCTION_DECL) + return; + TREE_ASM_WRITTEN (fn) = 1; + symtab_node *node = symtab_node::get (fn); + if (node) + node->remove (); +} + +/* Checkpoint every live discriminator slot. */ + +void * +save_lambda_discriminators (void) +{ + lambda_disc_checkpoint *ck = new lambda_disc_checkpoint; + snapshot_lambda_scope (ck->live, lambda_scope); + unsigned n = vec_safe_length (lambda_scope_stack); + for (unsigned i = 0; i < n; ++i) + { + lambda_scope_snap *snap = new lambda_scope_snap; + snapshot_lambda_scope (*snap, (*lambda_scope_stack)[i]); + ck->stack.safe_push (snap); + } + ck->outer = lambda_disc_current; + lambda_disc_current = ck; + return ck; +} + +/* Drop the probe's discriminator increments and its closures. */ + +void +restore_lambda_discriminators (void *p) +{ + lambda_disc_checkpoint *ck + = static_cast<lambda_disc_checkpoint *> (p); + gcc_assert (ck == lambda_disc_current); + for (unsigned i = 0; i < ck->lambdas.length (); ++i) + suppress_speculative_lambda (ck->lambdas[i]); + while (vec_safe_length (lambda_scope_stack) > ck->stack.length ()) + lambda_scope_stack->pop (); + unsigned n = vec_safe_length (lambda_scope_stack); + for (unsigned i = 0; i < n; ++i) + restore_lambda_scope_slot ((*lambda_scope_stack)[i], *ck->stack[i]); + restore_lambda_scope_slot (lambda_scope, ck->live); + lambda_disc_current = ck->outer; + delete ck; +} + +/* The probe stands. An enclosing probe still forgets these closures + if that probe is itself restored. */ + +void +discard_lambda_discriminators (void *p) +{ + lambda_disc_checkpoint *ck + = static_cast<lambda_disc_checkpoint *> (p); + gcc_assert (ck == lambda_disc_current); + if (ck->outer) + ck->outer->lambdas.safe_splice (ck->lambdas); + lambda_disc_current = ck->outer; + delete ck; +} + +/* Pre-C++20 unevaluated-lambda diagnostic, shared by the parser and + by substitution of a typeid operand. */ + +void +error_lambda_in_unevaluated_context (location_t loc) +{ + error_at (loc, "lambda-expression in unevaluated context" + " only available with %<-std=c++20%> or %<-std=gnu++20%>"); +} + +/* A lambda directly in an unevaluated typeid operand. Its body is + evaluated relative to the lambda, so the walk does not enter it. */ + +static tree +uneval_typeid_lambda_r (tree *tp, int *walk_subtrees, void *data) +{ + if (TREE_CODE (*tp) != LAMBDA_EXPR) + return NULL_TREE; + *walk_subtrees = 0; + auto_vec<location_t> *locs + = static_cast<auto_vec<location_t> *> (data); + locs->safe_push (LAMBDA_EXPR_LOCATION (*tp)); + return NULL_TREE; +} + +/* Diagnose pre-C++20 lambdas in EXPR, a typeid operand taken from + the template pattern. */ + +tree +reject_unevaluated_typeid_lambdas (tree expr, tsubst_flags_t complain) +{ + if (cxx_dialect >= cxx20 || !expr || expr == error_mark_node) + return expr; + auto_vec<location_t> locs; + cp_walk_tree_without_duplicates (&expr, uneval_typeid_lambda_r, &locs); + if (locs.is_empty ()) + return expr; + if (complain & tf_error) + { + for (unsigned i = 0; i < locs.length (); ++i) + error_lambda_in_unevaluated_context (locs[i]); + } + return error_mark_node; +} + // Record the per-scope discriminator of LAMBDA. If the extra scope // is empty, we must use the empty scope counter, which might not be // the live one. @@ -1776,6 +1998,7 @@ compare_lambda_sig (tree fn_a, tree fn_b) void record_lambda_scope_discriminator (tree lambda) { + note_speculative_lambda (lambda); auto *slot = (vec_safe_is_empty (lambda_scope_stack) || LAMBDA_EXPR_EXTRA_SCOPE (lambda) ? &lambda_scope : lambda_scope_stack->begin ()); @@ -1789,6 +2012,7 @@ record_lambda_scope_discriminator (tree lambda) void record_lambda_scope_sig_discriminator (tree lambda, tree fn) { + note_speculative_lambda (lambda); auto *slot = (vec_safe_is_empty (lambda_scope_stack) || LAMBDA_EXPR_EXTRA_SCOPE (lambda) ? &lambda_scope : lambda_scope_stack->begin ()); diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index f1e2207d8bd..027a532229e 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -300,6 +300,12 @@ int cp_unevaluated_operand; ([expr.prim.lambda.capture]/7). */ int cp_unevaluated_typeid_cutoff; +/* Locations of lambdas seen directly in the current typeid operand probe. + The probe is unevaluated even when expr.typeid/4 will evaluate the + operand, so a pre-C++20 lambda there is not yet known to be ill-formed + (PR c++/127750). */ +static vec<location_t, va_heap> *deferred_typeid_lambda_locs; + /* Nonzero if we are parsing a reflect-expression and shouldn't strip using-declarations. */ bool cp_preserve_using_decl; @@ -8647,11 +8653,16 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, else { tree expression; - /* [expr.typeid]/4-5: parse the operand unevaluated first; if it is - a polymorphic glvalue, roll back and re-parse it evaluated, - since an evaluated parse has irreversible side-effects - (mark_used -> instantiation; lambda capture). */ + /* [expr.typeid]/4-5: parse the operand unevaluated first; if it + is a polymorphic glvalue, roll back and re-parse it evaluated. + Lambda discriminators are not lexer state, so restore them + before that re-parse (PR c++/127750). */ cp_lexer_save_tokens (parser->lexer); + void *lambda_disc = save_lambda_discriminators (); + auto_vec<location_t> deferred_lambdas; + auto saved_defer + = make_temp_override (deferred_typeid_lambda_locs, + &deferred_lambdas); { cp_unevaluated u (/* typeid_operand= */ true); expression = cp_parser_expression (parser, &idk); @@ -8665,14 +8676,30 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, && !cp_unevaluated_operand && typeid_evaluated_p (expression)) { - /* Re-parse the operand evaluated so the /4 side-effects occur. - The unevaluated pass above called no mark_used and captured - nothing, so rolling back has nothing to undo. */ + /* The probe parsed a real lambda. Put the counters back + before parsing the closure that remains. */ + restore_lambda_discriminators (lambda_disc); cp_lexer_rollback_tokens (parser->lexer); expression = cp_parser_expression (parser, &idk); } else - cp_lexer_commit_tokens (parser->lexer); + { + /* The probe is the real parse. A lambda directly in it is + unevaluated, which pre-C++20 rejects. A dependent operand + is diagnosed when instantiated. */ + discard_lambda_discriminators (lambda_disc); + cp_lexer_commit_tokens (parser->lexer); + if (cxx_dialect < cxx20 + && expression != error_mark_node + && !deferred_lambdas.is_empty () + && !instantiation_dependent_expression_p (expression)) + { + for (location_t loc : deferred_lambdas) + error_lambda_in_unevaluated_context (loc); + expression = error_mark_node; + } + } + (void) saved_defer; /* Compute its typeid. */ postfix_expression = build_typeid (expression, tf_warning_or_error); @@ -12908,14 +12935,23 @@ cp_parser_lambda_expression (cp_parser* parser, /* C++20 allows lambdas in unevaluated context. */; else if (cp_unevaluated_operand) { - if (!token->error_reported) - { - error_at (LAMBDA_EXPR_LOCATION (lambda_expr), - "lambda-expression in unevaluated context" - " only available with %<-std=c++20%> or %<-std=gnu++20%>"); + /* The typeid probe is unevaluated even when expr.typeid/4 will + evaluate the operand. Defer the pre-C++20 diagnostic until that + is known (PR c++/127750). A deeper unevaluated operand, such as + sizeof inside the probe, still errors immediately. */ + if (deferred_typeid_lambda_locs + && cp_unevaluated_operand == cp_unevaluated_typeid_cutoff) + deferred_typeid_lambda_locs->safe_push + (LAMBDA_EXPR_LOCATION (lambda_expr)); + else if (!token->error_reported) + { + error_lambda_in_unevaluated_context + (LAMBDA_EXPR_LOCATION (lambda_expr)); token->error_reported = true; + ok = false; } - ok = false; + else + ok = false; } else if (parser->in_template_argument_list_p || processing_template_parmlist) { diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 2a703330173..24e0596e73e 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -23166,12 +23166,13 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) } else { - /* [expr.typeid]/4-5: substitute the operand unevaluated first, then - again evaluated if it is a polymorphic glvalue, so the /4 - side-effects occur. The unevaluated pass instantiates nothing, - so re-substituting has nothing to undo (PR c++/125886). */ + /* [expr.typeid]/4-5: substitute the operand unevaluated first, + then again evaluated if it is a polymorphic glvalue. + Restore lambda discriminators around that second pass so the + probe does not consume the surviving closure (PR c++/127750). */ tree operand; tree uneval; + void *lambda_disc = save_lambda_discriminators (); { cp_unevaluated u (/* typeid_operand= */ true); uneval = RECUR (operand_0); @@ -23181,9 +23182,22 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) of [expr.typeid]/4 ([basic.def.odr]/3), so the evaluated re-parse below can have nothing to do; skip it. */ if (!cp_unevaluated_operand && typeid_evaluated_p (uneval)) - operand = RECUR (operand_0); + { + restore_lambda_discriminators (lambda_disc); + operand = RECUR (operand_0); + } else - operand = uneval; + { + discard_lambda_discriminators (lambda_disc); + operand = uneval; + if (cxx_dialect < cxx20) + { + tree checked + = reject_unevaluated_typeid_lambdas (operand_0, complain); + if (checked == error_mark_node) + operand = error_mark_node; + } + } RETURN (build_typeid (operand, complain, TREE_TYPE (t))); } } diff --git a/gcc/testsuite/g++.dg/rtti/typeid-lambda-disc-pr127750.C b/gcc/testsuite/g++.dg/rtti/typeid-lambda-disc-pr127750.C new file mode 100644 index 00000000000..afda7da721c --- /dev/null +++ b/gcc/testsuite/g++.dg/rtti/typeid-lambda-disc-pr127750.C @@ -0,0 +1,43 @@ +// PR c++/127750 + +// See: https://itanium-cxx-abi.github.io/cxx-abi/abi.html#closure-types + +// The unevaluated typeid probe must not consume the lambda that +// [expr.typeid]/4 then parses evaluated. Discriminator 0 mangles as +// UlvE_; the next closure of the same signature in that function is +// UlvE0_. UlvE1_ means the probe was counted as well. +// { dg-do compile { target c++11 } } +// { dg-options "-O0" } + +#include <typeinfo> + +struct B { virtual ~B (); }; + +void +g (B *p) +{ + (void) typeid (*[&] { return p; } ()); + (void) [&] { return p; } (); +} + +template <class T> +void +tmpl (T *p) +{ + (void) typeid (*[&] { return p; } ()); + (void) [&] { return p; } (); +} + +void +use (B *p) +{ + g (p); + tmpl (p); +} + +// The colon is the definition label. A second copy is the probe closure. +// { dg-final { scan-assembler-times "_ZZ1gP1BENKUlvE_clEv:" 1 } } +// { dg-final { scan-assembler-times "_ZZ1gP1BENKUlvE0_clEv:" 1 } } +// { dg-final { scan-assembler-times "_ZZ4tmplI1BEvPT_ENKUlvE_clEv:" 1 } } +// { dg-final { scan-assembler-times "_ZZ4tmplI1BEvPT_ENKUlvE0_clEv:" 1 } } +// { dg-final { scan-assembler-not "UlvE1_" } } diff --git a/gcc/testsuite/g++.dg/rtti/typeid-lambda-uneval-pr127750.C b/gcc/testsuite/g++.dg/rtti/typeid-lambda-uneval-pr127750.C new file mode 100644 index 00000000000..1d275e0b9c5 --- /dev/null +++ b/gcc/testsuite/g++.dg/rtti/typeid-lambda-uneval-pr127750.C @@ -0,0 +1,59 @@ +// PR c++/127750 +// A lambda is ill-formed before C++20 only when it really is inside an +// unevaluated operand. [expr.typeid]/4 evaluates a polymorphic glvalue, +// so the lambda there is well-formed. [expr.typeid]/5 leaves every +// other operand unevaluated, and that diagnostic stays. +// Capture of a polymorphic glvalue is covered by pr125886.C and +// typeid-lambda-capture-pr127132.C. +// { dg-do compile { target c++11 } } + +#include <typeinfo> + +struct A { }; +struct B { virtual ~B (); }; + +void +ok (B *p) +{ + (void) typeid (*[&] { return p; } ()); +} + +template <class T> +void +ok_tmpl (T *p) +{ + (void) typeid (*[&] { return p; } ()); +} + +template void ok_tmpl<B> (B *); + +void +bad (int n) +{ + (void) typeid ([&] { return n; } ()); + // { dg-error "unevaluated context" "" { target c++17_down } .-1 } +} + +void +bad_class (A *p) +{ + (void) typeid (*[&] { return p; } ()); + // { dg-error "unevaluated context" "" { target c++17_down } .-1 } +} + +void +bad_nested (int n) +{ + (void) typeid (sizeof ([&] { return n; } ())); + // { dg-error "unevaluated context" "" { target c++17_down } .-1 } +} + +template <class T> +void +bad_tmpl (T n) +{ + (void) typeid ([&] { return n; } ()); + // { dg-error "unevaluated context" "" { target c++17_down } .-1 } +} + +template void bad_tmpl<int> (int); base-commit: 92a95b5e20929eb363f849170236271ce6973b43 -- 2.43.0
