https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116385

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Jason Merrill <[email protected]>:

https://gcc.gnu.org/g:621661f7d2e9157b7e5d55fc493e1b6956a35aac

commit r17-2200-g621661f7d2e9157b7e5d55fc493e1b6956a35aac
Author: Vladislav Semykin <[email protected]>
Date:   Tue Jul 7 12:52:08 2026 -0400

    c++: fix unevaluated operand context for typeid [PR125886]

    Per [expr.typeid]/4-5, a typeid operand is unevaluated by default and
    is evaluated only for a glvalue of polymorphic class type whose dynamic
    type is not known at compile time.  Previously GCC always parsed the
    operand in an evaluated context, which broke unevaluated uses (declval,
    non-static data members per DR613, function parameters) and missed
    lambda capture diagnostics for evaluated polymorphic operands.

    Implement a two-pass parse: first under cp_unevaluated, then - if
    typeid_evaluated_p says the operand is evaluated - roll back and
    re-parse under cp_evaluated.  Share the evaluated/unevaluated predicate
    via typeid_evaluated_p in rtti.cc, used from the parser, tsubst_expr,
    and build_typeid.

    Also fixes PR c++/68604 and PR c++/116385, and removes a now-stale xfail
    in g++.dg/coroutines/unevaluated.C.

            PR c++/125886
            PR c++/116385
            PR c++/68604

    gcc/cp/ChangeLog:
            * parser.cc (cp_parser_postfix_expression): Two-pass typeid parse.
            * pt.cc (tsubst_expr): Same for TYPEID_EXPR.
            * rtti.cc (typeid_evaluated_p, build_typeid): Shared predicate.
            * cp-tree.h: Declare typeid_evaluated_p.

    gcc/testsuite/ChangeLog:
            * g++.dg/cpp0x/pr125886.C: New test.
            * g++.dg/rtti/typeid14.C, g++.dg/rtti/typeid15.C: New tests.
            * g++.dg/coroutines/unevaluated.C: Drop stale xfail.

    Signed-off-by: Vladislav Semykin <[email protected]>
  • [Bug c++/116385] Unevaluat... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to