[PATCH] D41217: [Concepts] Concept Specialization Expressions

Saar Raz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 16 23:36:26 PDT 2018

saar.raz added inline comments.

Comment at: lib/AST/ExprCXX.cpp:1478
+  {
+    // We do not want error diagnostics escaping here.
+    Sema::SFINAETrap Trap(S);
hubert.reinterpretcast wrote:
> saar.raz wrote:
> > faisalv wrote:
> > > Hubert: This needs a TODO: the idea is not to drop SFINAE errors, but to avoid instantiation that may trigger errors not in the immediate context of instantiation. The substitution needs to happen piecewise.
> > Could you elaborate/give an example where this handling is inappropriate?
> Determining satisfaction requires normalization (lazy normalization should be considered).
> The determination of satisfaction then proceeds by handling the left-hand side of conjunction and disjunction constraints before possibly substituting into the right-hand side; i.e., there is short-circuiting behaviour.
> Example:
> ```
> template <typename T>
> concept C = true;
> template <typename T>
> struct Q { static constexpr T value = nullptr; };
> template <typename T>
> requires C<T> || T::value
> struct A { };
> template <typename T>
> requires C<T> || Q<T>::value
> struct B { };
> A<int> a; // okay
> B<int> b; // okay
> ```
OK I see your point. You said this should be a TODO - do you think this should be delayed to a further patch (namely D41569, where we actually deal with diagnostics and stuff)?
About lazy normalization, I tend to think it is not a good idea - you'll probably check satisfaction for every defined constraint expression at some point, and do that many more times than you'd define a new one

  rC Clang


More information about the cfe-commits mailing list