[PATCH] D120255: [Concepts] Check constraints for explicit template instantiations

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 2 06:09:20 PST 2022


erichkeane added a comment.

In D120255#3352920 <https://reviews.llvm.org/D120255#3352920>, @royjacobson wrote:

> In D120255#3352755 <https://reviews.llvm.org/D120255#3352755>, @erichkeane wrote:
>
>> Hmm... doing FileCheck in a Sema test is highly irregular.  I would expect us to be able to test this in the type system in some way.  Something like `A<3>::f()` is invalid (see -verify).
>>
>> Also, please add all the context (as requested above!) with the -U9999 stuff.
>
> I couldn't think of a way to "internally" know whether some function got instantiated. I also saw some other instantiation tests do it this way (SemaTemplate/instantiate-friend-function.cpp, SemaTemplate/inject-templated-friend.cpp). But I'm really not familiar enough with the code structure to have an opinion about this..
>
> Also, as I wrote in the description - function explicit instantiation doesn't check constraints either but it's a different code path, so, `A<3>::f()` currently fails for the wrong reason. It will just try to instantiate the first function it finds and then fail the static assert and not the constraint.
> (Or worse, fail the internal assert in `SemaTemplate.cpp:10161` if clang was built with assertions).

The only other idea I have (other than finding a static-assert of some sort) is to do an AST level test instead, so use `-ast-dump` and check that it appears/not appears in the AST instead?  That way at least the ordering will be more reliable.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120255/new/

https://reviews.llvm.org/D120255



More information about the cfe-commits mailing list