Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -125,6 +125,8 @@ of a base class is not called in the constructor of its derived class. - Clang no longer emits ``-Wmissing-variable-declarations`` for variables declared with the ``register`` storage class. +- Clang no longer emits irrelevant notes about unsatisfied constraint expressions + on the left-hand side of ``||`` when the right-hand side constraint is satisfied. Bug Fixes in This Version ------------------------- Index: clang/lib/Sema/SemaConcept.cpp =================================================================== --- clang/lib/Sema/SemaConcept.cpp +++ clang/lib/Sema/SemaConcept.cpp @@ -183,6 +183,7 @@ ConstraintExpr = ConstraintExpr->IgnoreParenImpCasts(); if (LogicalBinOp BO = ConstraintExpr) { + auto EffectiveDetailEnd = Satisfaction.Details.end(); ExprResult LHSRes = calculateConstraintSatisfaction( S, BO.getLHS(), Satisfaction, Evaluator); @@ -216,6 +217,11 @@ if (RHSRes.isInvalid()) return ExprError(); + bool IsRHSSatisfied = Satisfaction.IsSatisfied; + if (BO.isOr() && IsRHSSatisfied) + Satisfaction.Details.erase(EffectiveDetailEnd, + Satisfaction.Details.end()); + return BO.recreateBinOp(S, LHSRes, RHSRes); } Index: clang/test/SemaTemplate/concepts.cpp =================================================================== --- clang/test/SemaTemplate/concepts.cpp +++ clang/test/SemaTemplate/concepts.cpp @@ -994,3 +994,40 @@ } } + +namespace GH54678 { +template +concept True = true; + +template +concept False = false; // expected-note 9 {{'false' evaluated to false}} + +template +concept Irrelevant = false; + +template +concept ErrorRequires = requires(ErrorRequires auto x) { x; }; // expected-error {{unknown type name 'ErrorRequires'}} + +template void aaa(T t) // expected-note {{candidate template ignored: constraints not satisfied}} +requires (False || False) || False {} // expected-note 3 {{'int' does not satisfy 'False'}} +template void bbb(T t) // expected-note {{candidate template ignored: constraints not satisfied}} +requires (False || False) && True {} // expected-note 2 {{'long' does not satisfy 'False'}} +template void ccc(T t) // expected-note {{candidate template ignored: constraints not satisfied}} +requires (True || Irrelevant) && False {} // expected-note {{'unsigned long' does not satisfy 'False'}} +template void ddd(T t) // expected-note {{candidate template ignored: constraints not satisfied}} +requires (Irrelevant || True) && False {} // expected-note {{'int' does not satisfy 'False'}} +template void eee(T t) // expected-note {{candidate template ignored: constraints not satisfied}} +requires (Irrelevant || Irrelevant || True) && False {} // expected-note {{'long' does not satisfy 'False'}} + +template void fff(T t) // expected-note {{candidate template ignored: constraints not satisfied}} +requires((ErrorRequires || False || True) && False) {} // expected-note {{'unsigned long' does not satisfy 'False'}} + +void test() { + aaa(42); // expected-error {{no matching function}} + bbb(42L); // expected-error{{no matching function}} + ccc(42UL); // expected-error {{no matching function}} + ddd(42); // expected-error {{no matching function}} + eee(42L); // expected-error {{no matching function}} + fff(42UL); // expected-error {{no matching function}} +} +}