[PATCH] D25866: [Sema] Support implicit scalar to vector conversions
Bruno Cardoso Lopes via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 25 09:15:54 PDT 2016
bruno added a comment.
Hi,
Nice, thanks for working on this!
================
Comment at: lib/Sema/SemaExpr.cpp:8051
+ if (!LHSVecType) {
+ assert(RHSVecType && "RHSVecType is not a vector!");
if (!tryVectorConvertAndSplat(*this, (IsCompAssign ? nullptr : &LHS),
----------------
`tryVectorConvertAndSplat` does more than plain scalar splat; it supports a more general type of CK_IntegralCast, see the comment on one of your changes to the tests below.
I suggest that instead of reusing this function, you should create another one that only handles the cases we actually want to support for non-ext vectors (i.e. for GCC compat).
================
Comment at: test/Sema/vector-cast.c:57
+ // FIXME: This lacks a diagnostic: should complain that 'double' to vector 'float2' involves truncation
+ f2 += d;
+ d += f2; // expected-error {{assigning to 'double' from incompatible type 'float2' (vector of 2 'float' values)}}
----------------
This is not right. The fact that we don't have the appropriate diagnostics here doesn't mean we should accept this. For instance, this is what we get with GCC:
error: conversion of scalar 'double' to vector 'float2 {aka __vector(2) float}' involves truncation
================
Comment at: test/Sema/vector-scalar-implict-conv.c:2
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Weverything
+
+typedef long long v2i64 __attribute__((vector_size(16)));
----------------
Can you rename this to vector-gcc-compat.c? It would also be nice to split functionality being tested within their own function, e.g.: arithmetic, logic, vector comparisons.
https://reviews.llvm.org/D25866
More information about the cfe-commits
mailing list