[PATCH] D71463: Implement VectorType conditional operator GNU extension.

Eli Friedman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 13 11:10:17 PST 2019


efriedma added a comment.

Can you update https://clang.llvm.org/docs/LanguageExtensions.html#langext-vectors with a description of the interaction between the different language features here?

It's unfortunate that the gcc extension is explicitly incompatible with OpenCL, but I guess we're stuck with it.



================
Comment at: clang/include/clang/AST/Expr.h:3738
+            // implementation of this that the standard implies that this
+            // could be true in the C++ standard as well.
+            (cond->isTypeDependent() || lhs->isTypeDependent() ||
----------------
You can just refer to [temp.dep.expr] here; the type does in fact "depend" on the type of the condition.  I'm a little concerned that the C++ standard might not preserve this guarantee in the future.


================
Comment at: clang/lib/Sema/SemaExpr.cpp:8981
+    else
+      return true;
   } else if (VectorEltTy->isRealFloatingType()) {
----------------
Can you separate this out into an independent patch?


================
Comment at: clang/lib/Sema/SemaExprCXX.cpp:5826
+    else
+      ResultElementTy = UsualArithmeticConversions(LHS, RHS);
+
----------------
I'm not completely sure this works the way you want it to... in particular, if the types don't match, and both operands can be promoted to int, you end up with an int vector.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71463/new/

https://reviews.llvm.org/D71463





More information about the cfe-commits mailing list