[clang][SVE] Don't warn on vector to sizeless builtin implicit conversion
authorJoe Ellis <joe.ellis@arm.com>
Fri, 19 Feb 2021 17:09:50 +0000 (17:09 +0000)
committerJoe Ellis <joe.ellis@arm.com>
Tue, 23 Feb 2021 13:40:58 +0000 (13:40 +0000)
commit1b1b30cf0f7d9619afb32e16f4a7c007da4ffccf
tree70d788cfe5029262993332fd29a4f3905b2d33b5
parent2c54b293373ce22cd912ea50fece504b26f2bdc4
[clang][SVE] Don't warn on vector to sizeless builtin implicit conversion

This commit prevents warnings from -Wconversion when a clang vector type
is implicitly converted to a sizeless builtin type -- for example, when
implicitly converting a fixed-predicate to a scalable predicate.

The code below:

     1    #include <arm_sve.h>
     2
     3    #define N __ARM_FEATURE_SVE_BITS
     4    #define FIXED_ATTR __attribute__((arm_sve_vector_bits (N)))
     5    typedef svbool_t fixed_svbool_t FIXED_ATTR;
     6
     7    inline fixed_svbool_t foo(fixed_svbool_t p) {
     8      return svnot_z(svptrue_b64(), p);
     9    }

would previously raise this warning:

    warning: implicit conversion turns vector to scalar: \
    'fixed_svbool_t' (vector of 8 'unsigned char' values) to 'svbool_t' \
    (aka '__SVBool_t') [-Wconversion]

Note that many cases of these implicit conversions were already
permitted because many functions inside arm_sve.h are spawned via
preprocessor macros, and the call to isInSystemMacro would cover us in
this case. This commit fixes the remaining cases.

Differential Revision: https://reviews.llvm.org/D97053
clang/lib/Sema/SemaChecking.cpp
clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp