Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions clang/lib/Sema/SemaOverload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6470,6 +6470,12 @@ static ExprResult BuildConvertedConstantExpression(Sema &S, Expr *From,
S.Diag(From->getBeginLoc(), diag::ext_cce_narrowing)
<< CCE << /*Constant*/ 1
<< PreNarrowingValue.getAsString(S.Context, PreNarrowingType) << T;
// If this is an SFINAE Context, treat the result as invalid so it stops
// substitution at this point, respecting C++26 [temp.deduct.general]p7.
// FIXME: Should do this whenever the above diagnostic is an error, but
// without further changes this would degrade some other diagnostics.
if (S.isSFINAEContext())
return ExprError();
break;

case NK_Dependent_Narrowing:
Expand All @@ -6485,6 +6491,8 @@ static ExprResult BuildConvertedConstantExpression(Sema &S, Expr *From,
// constant expression.
S.Diag(From->getBeginLoc(), diag::ext_cce_narrowing)
<< CCE << /*Constant*/ 0 << From->getType() << T;
if (S.isSFINAEContext())
return ExprError();
break;
}
if (!ReturnPreNarrowingValue)
Expand Down
11 changes: 10 additions & 1 deletion clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void TempFunc() {}

void Useage() {
//expected-error@+2 {{no matching function}}
//expected-note@-4 {{candidate template ignored: substitution failure [with a = 1, b = 4294967295, c = 1]: non-type template argument evaluates to -1, which cannot be narrowed to type 'unsigned int'}}
//expected-note@-4 {{candidate template ignored: invalid explicitly-specified argument for template parameter 'b'}}
TempFunc<1, -1, 1>();
}
}
Expand Down Expand Up @@ -114,3 +114,12 @@ void lookup() {
Kolumn<&container::a>().ls(); // expected-error {{<&container::a}}
Kolumn<nullptr>().ls(); // expected-error {{<nullptr}}
}

namespace GH167709 {
template <unsigned I> struct A {
static_assert(false, "shouldn't instantiate this");
};
template <int> void f() {}
template <int I> typename A<I>::type f() = delete;
template void f<-1>();
} // namespace GH167709
Loading