[PATCH] D25866: [Sema] Support implicit scalar to vector conversions

Simon Dardis via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 5 06:43:57 PDT 2017


sdardis marked an inline comment as done.
sdardis added a comment.

Thanks for sticking with this.

I've held off updating the diff until https://reviews.llvm.org/D31667 (not https://reviews.llvm.org/D31337 as previously posted) is finished. Responses inlined.



================
Comment at: lib/Sema/SemaExpr.cpp:8188
+  //        type and then perform the rest of the checks here. GCC as of
+  //        pre-release 7.0 does not accept this though.
+  if (VectorEltTy->isIntegralType(S.Context) &&
----------------
bruno wrote:
> Is this something that GCC is going to support at some point? Regardless of GCC, do we want this behavior?
> Is this something that GCC is going to support at some point?

I've reread GCC's source for conversions of scalar to vectors types and it appears that GCC does attempt to convert constant real expressions to integers but it appears to only work for C++. It's a little odd.

> Regardless of GCC, do we want this behavior?

Given my oversight of the support of implicit safe conversions of floating point constants to integer types, I believe we should do this in general. I'll rework the comment to be more accurate and add the necessary conversion checks.


================
Comment at: lib/Sema/SemaExpr.cpp:10019
       isa<ExtVectorType>(vType->getAs<VectorType>()) || getLangOpts().OpenCL;
+  if ((!getLangOpts().CPlusPlus && !getLangOpts().OpenCL) && !isExtVectorType)
+    return InvalidVectorOperands(Loc, LHS, RHS);
----------------
bruno wrote:
> Why `!getLangOpts().CPlusPlus` is a requirement here?
GCC only supports the logical operators &&, ||, ! when compiling C++.

It's noted near the bottom half of this page: https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html


================
Comment at: test/Sema/vector-g++-compat.cpp:155
+                           unsigned long long d) { // expected-warning {{'long long' is incompatible with C++98}}
+
+  v4f32 v4f32_a = {0.4f, 0.4f, 0.4f, 0.4f};
----------------
bruno wrote:
> Remove all these extra new lines after the function signature here, in the functions below and in the other added test file for c++.
Will do.


https://reviews.llvm.org/D25866





More information about the cfe-commits mailing list