]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: Document why TARGET_EXPR is not handled in tsubst_expr
authorEgas Ribeiro <egas.g.ribeiro@tecnico.ulisboa.pt>
Mon, 8 Dec 2025 18:04:42 +0000 (18:04 +0000)
committerPatrick Palka <ppalka@redhat.com>
Mon, 8 Dec 2025 19:28:21 +0000 (14:28 -0500)
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 <egas.g.ribeiro@tecnico.ulisboa.pt>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
gcc/cp/pt.cc

index a9b311be9ac40d2e38359dc4725b73d5925b4968..ce30b52766383d4fbe8dd66aec02cc7576e15bff 100644 (file)
@@ -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