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

Simon Dardis via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 18 05:29:23 PDT 2017


sdardis added a comment.

Realised I've some comments to submit.



================
Comment at: lib/Sema/SemaExpr.cpp:8032
+
+  return InvalidOperands(Loc, LHS, RHS);
+}
----------------
bruno wrote:
> Double checking here: are there tests for the `InvalidOperands` case above?
Yes, this case is covered in the new diff in test/Sema/vector-ops.c and in test/Sema/vector-gcc-compat.c . 


================
Comment at: lib/Sema/SemaExpr.cpp:10024
+  // FIXME: The check for C++ here is for GCC compatibility. GCC rejects the
+  //        usage of logical operators with vectors in C. This check could be
+  //        notionally dropped.
----------------
bruno wrote:
> Please mention in the comment the list of logical ops that this applies to: "!, &&, ||"
I've updated the relevant Check* functions with FIXME:s noting that they should handle vector types for compatibility with GCC.


================
Comment at: test/Sema/vector-gcc-compat.c:101
+
+  v2i64_r = v2i64_a && 1; // expected-error {{invalid vector operand to binary expression ('v2i64' (vector of 2 'long long' values))}}
+  v2i64_r = v2i64_a || 1; // expected-error {{invalid vector operand to binary expression ('v2i64' (vector of 2 'long long' values))}}
----------------
bruno wrote:
> Is this because of && and others only working in C++? If so, we need a better error message here, along the lines of "logical expression with vector only support in C++". If later on we decide to support it in non-C++, we then get rid of the warning.
> 
> 
> 
Yes, these operators are oddly only available in C++.

I've changed the error message to "logical expression with vector type[s] '<typedef'd name>' (vector of <N> '<element type>' values) [and '<other type>'] is only supported in C++".


https://reviews.llvm.org/D25866





More information about the cfe-commits mailing list