]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: CTAD and trait built-ins
authorJason Merrill <jason@redhat.com>
Wed, 3 Jul 2024 21:27:48 +0000 (17:27 -0400)
committerJason Merrill <jason@redhat.com>
Thu, 4 Jul 2024 02:04:50 +0000 (22:04 -0400)
While poking at 101232 I noticed that we started trying to parse
__is_invocable(_Fn, _Args...) as a functional cast to a CTAD placeholder
type; we shouldn't consider CTAD for a template that shares a name (reserved
for the implementation) with a built-in trait.

gcc/cp/ChangeLog:

* pt.cc (ctad_template_p): Return false for trait names.

gcc/cp/pt.cc

index 017cc7fd0abcbf53883fa62b84c65d206d0bd15a..d1316483e2455aa2700ffff45134506d0d14c2f3 100644 (file)
@@ -30811,6 +30811,11 @@ ctad_template_p (tree tmpl)
      where the nested-name-specifier (if any) is non-dependent and the
      template-name of the simple-template-id names a deducible template.  */
 
+  if (DECL_CLASS_TEMPLATE_P (tmpl)
+      && IDENTIFIER_TRAIT_P (DECL_NAME (tmpl)))
+    /* Don't consider CTAD for templates with the same name as a trait; that
+       is ambiguous with e.g. __is_invocable(_Fn,_Args...).  */
+    return false;
   if (DECL_CLASS_TEMPLATE_P (tmpl)
       || DECL_TEMPLATE_TEMPLATE_PARM_P (tmpl))
     return true;