https://gcc.gnu.org/g:24efdb0974e19f9c31731dc0d8bdf52044705b50

commit r16-5970-g24efdb0974e19f9c31731dc0d8bdf52044705b50
Author: Egas Ribeiro <[email protected]>
Date:   Mon Dec 8 18:04:42 2025 +0000

    c++: Document why TARGET_EXPR is not handled in tsubst_expr
    
    TARGET_EXPR represents semantic temporary objects and is deliberately
    not handled by tsubst routines, which expect syntactic templated trees.
    Add a comment and gcc_unreachable to make this explicit.
    
    gcc/cp/ChangeLog:
    
            * pt.cc (tsubst_expr): Add TARGET_EXPR case with explanatory
            comment and gcc_unreachable.
    
    Signed-off-by: Egas Ribeiro <[email protected]>
    Reviewed-by: Patrick Palka <[email protected]>

Diff:
---
 gcc/cp/pt.cc | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index a9b311be9ac4..ce30b5276638 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -22562,6 +22562,11 @@ tsubst_expr (tree t, tree args, tsubst_flags_t 
complain, tree in_decl)
         in response to the saved STMT_IS_FULL_EXPR_P setting.  */
       gcc_unreachable ();
 
+    case TARGET_EXPR:
+      /* TARGET_EXPR represents temporary objects and should not appear in
+        templated trees.  */
+      gcc_unreachable ();
+
     case OFFSET_REF:
       {
        /* We should only get here for an OFFSET_REF like A::m; a .* in a

Reply via email to