From ff91735a5b861dd6eaf2c1e511f26a9255898e7d Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Fri, 13 May 2022 20:09:53 -0400 Subject: [PATCH] c++: Add !TYPE_P assert to type_dependent_expression_p [PR99080] As discussed here: , type_dependent_expression_p should not be called with a type argument. I promised I'd add an assert so here it is. One place needed adjusting. PR c++/99080 gcc/cp/ChangeLog: * pt.cc (type_dependent_expression_p): Assert !TYPE_P. * semantics.cc (finish_id_expression_1): Handle UNBOUND_CLASS_TEMPLATE specifically. --- gcc/cp/pt.cc | 2 ++ gcc/cp/semantics.cc | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index f1f0805..f573ca8 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -27734,6 +27734,8 @@ type_dependent_expression_p (tree expression) if (expression == NULL_TREE || expression == error_mark_node) return false; + gcc_checking_assert (!TYPE_P (expression)); + STRIP_ANY_LOCATION_WRAPPER (expression); /* An unresolved name is always dependent. */ diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index cdc91a3..1d012d6 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -4139,6 +4139,15 @@ finish_id_expression_1 (tree id_expression, } return r; } + else if (TREE_CODE (decl) == UNBOUND_CLASS_TEMPLATE) + { + gcc_checking_assert (scope); + *idk = CP_ID_KIND_QUALIFIED; + cp_warn_deprecated_use_scopes (scope); + decl = finish_qualified_id_expr (scope, decl, done, address_p, + template_p, template_arg_p, + tf_warning_or_error); + } else { bool dependent_p = type_dependent_expression_p (decl); -- 2.7.4