aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/StackProtector.cpp
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2020-02-27 11:01:02 +0000
committerRichard Sandiford <richard.sandiford@arm.com>2020-03-17 11:24:57 +0000
commit010005f0774e13475c321f78b89bdc79eb78d5a5 (patch)
treeafed984f9f57ded86666a370c404f822145f8078 /llvm/lib/CodeGen/StackProtector.cpp
parent4dd5f1ca9b2b7ae50849efeb7cf3ecfbdb1cf67a (diff)
downloadllvm-010005f0774e13475c321f78b89bdc79eb78d5a5.zip
llvm-010005f0774e13475c321f78b89bdc79eb78d5a5.tar.gz
llvm-010005f0774e13475c321f78b89bdc79eb78d5a5.tar.bz2
[Sema][SVE] Reject subscripts on pointers to sizeless types
clang currently accepts: __SVInt8_t &foo1(__SVInt8_t *x) { return *x; } __SVInt8_t &foo2(__SVInt8_t *x) { return x[1]; } The first function is valid ACLE code and generates correct LLVM IR (and assembly code). But the second function is invalid for the same reason that arrays of sizeless types are. Trying to code-generate the function leads to: llvm/include/llvm/Support/TypeSize.h:126: uint64_t llvm::TypeSize::getFixedSize() const: Assertion `!IsScalable && "Request for a fixed size on a s calable object"' failed. Another problem is that: template<typename T> constexpr __SIZE_TYPE__ f(T *x) { return &x[1] - x; } typedef int arr1[f((int *)0) - 1]; typedef int arr2[f((__SVInt8_t *)0) - 1]; produces: a.cpp:2:48: warning: subtraction of pointers to type '__SVInt8_t' of zero size has undefined behavior [-Wpointer-arith] constexpr __SIZE_TYPE__ f(T *x) { return &x[1] - x; } ~~~~~ ^ ~ a.cpp:4:18: note: in instantiation of function template specialization 'f<__SVInt8_t>' requested here typedef int arr2[f((__SVInt8_t *)0) - 1]; This patch reports an appropriate diagnostic instead. Differential Revision: https://reviews.llvm.org/D76084
Diffstat (limited to 'llvm/lib/CodeGen/StackProtector.cpp')
0 files changed, 0 insertions, 0 deletions