@@ -410,8 +410,8 @@ void SingleDepthReferencesTopCalled(U &&u) {
410
410
411
411
template <typename U>
412
412
void SingleDepthReferencesTopLambda (U &&u) {
413
- []()
414
- requires IsInt<decltype (u)>
413
+ []() // #SDRTL_OP
414
+ requires IsInt<decltype (u)> // #SDRTL_REQ
415
415
{}();
416
416
}
417
417
@@ -434,8 +434,8 @@ void DoubleDepthReferencesTop(U &&u) {
434
434
435
435
template <typename U>
436
436
void DoubleDepthReferencesTopLambda (U &&u) {
437
- []() { []()
438
- requires IsInt<decltype (u)>
437
+ []() { []() // #DDRTL_OP
438
+ requires IsInt<decltype (u)> // #DDRTL_REQ
439
439
{}(); }();
440
440
}
441
441
@@ -459,10 +459,11 @@ void DoubleDepthReferencesAll(U &&u) {
459
459
460
460
template <typename U>
461
461
void DoubleDepthReferencesAllLambda (U &&u) {
462
- [](U &&u2) {
463
- [](U && u3)
464
- requires IsInt<decltype (u)> &&
465
- IsInt<decltype (u2)> && IsInt<decltype (u3)>
462
+ [](U &&u2) { // #DDRAL_OP1
463
+ [](U && u3) // #DDRAL_OP2
464
+ requires IsInt<decltype (u)> // #DDRAL_REQ
465
+ && IsInt<decltype (u2)>
466
+ && IsInt<decltype (u3)>
466
467
{}(u2);
467
468
}(u);
468
469
}
@@ -484,8 +485,8 @@ struct CausesFriendConstraint {
484
485
template <typename T>
485
486
void ChecksLocalVar (T x) {
486
487
T Local;
487
- []()
488
- requires (IsInt<decltype (Local)>)
488
+ []() // #CLV_OP
489
+ requires (IsInt<decltype (Local)>) // #CLV_REQ
489
490
{}();
490
491
}
491
492
@@ -527,8 +528,12 @@ void test_dependent() {
527
528
SingleDepthReferencesTopNotCalled (will_fail);
528
529
SingleDepthReferencesTopCalled (v); // #SDRTC
529
530
SingleDepthReferencesTopLambda (v);
530
- // FIXME: This should error on constraint failure! (Lambda!)
531
531
SingleDepthReferencesTopLambda (will_fail);
532
+ // expected-note@-1{{in instantiation of function template specialization}}
533
+ // expected-error@#SDRTL_OP{{no matching function for call to object of type}}
534
+ // expected-note@#SDRTL_OP{{candidate function not viable: constraints not satisfied}}
535
+ // expected-note@#SDRTL_REQ{{because 'IsInt<decltype(u)>' evaluated to false}}
536
+
532
537
DoubleDepthReferencesTop (v);
533
538
DoubleDepthReferencesTop (will_fail);
534
539
// expected-error@#DDRT_CALL{{no matching function for call to object of type 'lc2'}}
@@ -538,8 +543,12 @@ void test_dependent() {
538
543
// expected-note@#DDRT_REQ{{'IsInt<decltype(u)>' evaluated to false}}
539
544
540
545
DoubleDepthReferencesTopLambda (v);
541
- // FIXME: This should error on constraint failure! (Lambda!)
542
546
DoubleDepthReferencesTopLambda (will_fail);
547
+ // expected-note@-1{{in instantiation of function template specialization}}
548
+ // expected-error@#DDRTL_OP{{no matching function for call to object of type}}
549
+ // expected-note@#DDRTL_OP{{candidate function not viable: constraints not satisfied}}
550
+ // expected-note@#DDRTL_OP{{while substituting into a lambda expression here}}
551
+ // expected-note@#DDRTL_REQ{{because 'IsInt<decltype(u)>' evaluated to false}}
543
552
DoubleDepthReferencesAll (v);
544
553
DoubleDepthReferencesAll (will_fail);
545
554
// expected-error@#DDRA_CALL{{no matching function for call to object of type 'lc2'}}
@@ -549,8 +558,12 @@ void test_dependent() {
549
558
// expected-note@#DDRA_REQ{{'IsInt<decltype(u)>' evaluated to false}}
550
559
551
560
DoubleDepthReferencesAllLambda (v);
552
- // FIXME: This should error on constraint failure! (Lambda!)
553
561
DoubleDepthReferencesAllLambda (will_fail);
562
+ // expected-note@-1{{in instantiation of function template specialization}}
563
+ // expected-note@#DDRAL_OP1{{while substituting into a lambda expression here}}
564
+ // expected-error@#DDRAL_OP2{{no matching function for call to object of type}}
565
+ // expected-note@#DDRAL_OP2{{candidate function not viable: constraints not satisfied}}
566
+ // expected-note@#DDRAL_REQ{{because 'IsInt<decltype(u)>' evaluated to false}}
554
567
555
568
CausesFriendConstraint<int > CFC;
556
569
FriendFunc (CFC, 1 );
@@ -563,8 +576,13 @@ void test_dependent() {
563
576
// ChecksCapture(v);
564
577
565
578
ChecksLocalVar (v);
566
- // FIXME: This should error on constraint failure! (Lambda!)
567
579
ChecksLocalVar (will_fail);
580
+ // expected-note@-1{{in instantiation of function template specialization}}
581
+ // expected-error@#CLV_OP{{no matching function for call to object of type}}
582
+ // expected-note@#CLV_OP{{candidate function not viable: constraints not satisfied}}
583
+ // expected-note@#CLV_REQ{{because 'IsInt<decltype(Local)>' evaluated to false}}
584
+
585
+
568
586
569
587
LocalStructMemberVar (v);
570
588
LocalStructMemberVar (will_fail);
@@ -701,6 +719,18 @@ namespace SelfFriend {
701
719
} // namespace SelfFriend
702
720
703
721
722
+ namespace Surrogates {
723
+ int f1 (int );
724
+ template <auto N>
725
+ struct A {
726
+ using F = int (int );
727
+ operator F*() requires N { return f1; } // expected-note{{conversion candidate 'operator int (*)(int)' not viable: constraints not satisfied}}
728
+ };
729
+ int i = A<true >{}(0 );
730
+ int j = A<false >{}(0 ); // expected-error{{no matching function for call to object of type 'A<false>'}}
731
+ }
732
+
733
+
704
734
namespace ConstrainedMemberVarTemplate {
705
735
template <long Size> struct Container {
706
736
static constexpr long arity = Size;
@@ -914,3 +944,53 @@ struct W0 {
914
944
915
945
static_assert (W0<0 >::W1<1 >::F<int >::value == 1 );
916
946
} // TemplateInsideTemplateInsideTemplate
947
+
948
+
949
+ namespace GH63181 {
950
+
951
+ template <auto N, class T > void f () {
952
+ auto l = []() requires N { }; // expected-note 2{{candidate function not viable: constraints not satisfied}} \
953
+ // expected-note 2{{because 'false' evaluated to false}}
954
+
955
+ l ();
956
+ // expected-error@-1 {{no matching function for call to object of type}}
957
+ void (*ptr)() = l;
958
+ // expected-error-re@-1 {{no viable conversion from '(lambda {{.*}})' to 'void (*)()'}}
959
+ }
960
+
961
+ template void f<false , int >(); // expected-note {{in instantiation of function template specialization 'GH63181::f<false, int>' requested here}}
962
+ template void f<true , int >();
963
+
964
+ template <class T > concept C = __is_same(T, int ); // expected-note{{because '__is_same(char, int)' evaluated to false}}
965
+
966
+ template <class ... Ts> void f () {
967
+ ([]() requires C<Ts> { return Ts (); }(), ...);
968
+ // expected-error@-1 {{no matching function for call to object of type}} \
969
+ // expected-note@-1 {{candidate function not viable: constraints not satisfied}} \
970
+ // expected-note@-1 {{because 'char' does not satisfy 'C'}}
971
+ }
972
+
973
+ template void f<int , int , int >();
974
+ template void f<int , int , char >();
975
+ // expected-note@-1{{in instantiation of function template specialization 'GH63181::f<int, int, char>' requested here}}
976
+
977
+
978
+ template <typename T, bool IsTrue>
979
+ concept Test = IsTrue; // expected-note 2{{because 'false' evaluated to false}}
980
+
981
+ template <typename T, bool IsTrue>
982
+ void params () {
983
+ auto l = [](T t) // expected-note 2{{candidate function not viable: constraints not satisfied}}
984
+ requires Test<decltype (t), IsTrue> // expected-note 2{{because 'Test<decltype(t), false>' evaluated to false}}
985
+ {};
986
+ using F = void (T);
987
+ F* f = l; // expected-error {{no viable conversion from}}
988
+ l (0 ); // expected-error {{no matching function for call to object}}
989
+ }
990
+
991
+ void test_params () {
992
+ params<int , true >();
993
+ params<int , false >(); // expected-note {{in instantiation of function template specialization 'GH63181::params<int, false>' requested here}}
994
+ }
995
+
996
+ }
0 commit comments