[clang] [clang][Sema] Allow abstract declarators to specify cv-qualified function types as per CWG1417 (PR #209836)

via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 17 09:15:45 PDT 2026


AZero13 wrote:

> Could you please elaborate the motivation of this PR?
> 
> > Exempted DeclaratorContext::TypeName from the check. Abstract declarator contexts (used by typeof, sizeof, C-style casts) now properly bypass this restricted rule, matching how TemplateArg was already correctly exempted.
> 
> Could you please explain the "properly"? It would be quite useful to reference C++ standard. I don't think "typeof, sizeof, C-style casts" are affected by CWG1417.

Currently there are only two ways to make a template that accepts either a value or a type, using class template overloads or wrapping the argument in typeof to convert values to types (decltype would work if it also accepted types, but it doesn't).

So even if you use a macro wrapper to hide the jank like
```#define EXAMPLE(arg) example<typeof(arg)>```
clang will completely fail in the specific edge case of abominable functions and there's no workaround without this.

As for the standard: I checked the other day when I saw the typeid comment and that's the only thing besides pointers/references that explicitly forbids cv-qualified function types.

https://github.com/llvm/llvm-project/pull/209836


More information about the cfe-commits mailing list