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.
---
 gcc/cp/pt.cc | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 4dc8f980d0d..19729cfe13d 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -22300,6 +22300,10 @@ tsubst_expr (tree t, tree args, tsubst_flags_t 
complain, tree in_decl)
            RETURN (build_typeid (operand_0, complain));
          }
       }
+    case TARGET_EXPR:
+      /* TARGET_EXPR represents temporary objects and should not appear in
+        templated trees.  (PR c++/117034)  */
+      gcc_unreachable ();
 
     case FUNCTION_DECL:
     case PARM_DECL:
-- 
2.52.0

Reply via email to