[clang] [clang] disallow narrowing when matching template template parameters (PR #124313)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 24 12:53:33 PST 2025
================
@@ -6930,17 +6934,20 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
IsConvertedConstantExpression = false;
}
- if (getLangOpts().CPlusPlus17) {
+ if (getLangOpts().CPlusPlus17 || PartialOrderingTTP) {
// C++17 [temp.arg.nontype]p1:
// A template-argument for a non-type template parameter shall be
// a converted constant expression of the type of the template-parameter.
APValue Value;
ExprResult ArgResult;
if (IsConvertedConstantExpression) {
- ArgResult = BuildConvertedConstantExpression(Arg, ParamType,
- CCEK_TemplateArg, Param);
- if (ArgResult.isInvalid())
+ ArgResult = BuildConvertedConstantExpression(
+ Arg, ParamType,
+ PartialOrderingTTP ? CCEK_InjectedTTP : CCEK_TemplateArg, Param);
+ if (ArgResult.isInvalid()) {
----------------
erichkeane wrote:
In every singe case I've seen this come up, it has meant either 'error' or 'there is nothing here'. And the question we usually ask is, "Can I do something with this". Which `isUsable` means. `isInvalid` means, "WAS something here, but there was a problem with it".
In this case, you're translating "There is nothing I can do with this" to "error". Which makes more sense as `isUsable` to me.
https://github.com/llvm/llvm-project/pull/124313
More information about the cfe-commits
mailing list