c++: Add !TYPE_P assert to type_dependent_expression_p [PR99080]
authorMarek Polacek <polacek@redhat.com>
Sat, 14 May 2022 00:09:53 +0000 (20:09 -0400)
committerMarek Polacek <polacek@redhat.com>
Mon, 30 May 2022 21:10:51 +0000 (17:10 -0400)
As discussed here:
<https://gcc.gnu.org/pipermail/gcc-patches/2021-February/564629.html>,
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
gcc/cp/semantics.cc

index f1f0805..f573ca8 100644 (file)
@@ -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.  */
index cdc91a3..1d012d6 100644 (file)
@@ -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);