[PATCH] D76082: [Sema][SVE] Reject arrays of sizeless types
Richard Sandiford via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 12 11:56:18 PDT 2020
rsandifo-arm created this revision.
rsandifo-arm added reviewers: sdesmalen, efriedma, rovka, rjmccall.
Herald added subscribers: cfe-commits, psnobl, rkruppe, tschuett.
Herald added a reviewer: rengolin.
Herald added a project: clang.
rsandifo-arm added a parent revision: D75738: [Sema][SVE] Reject by-copy capture of sizeless types.
rsandifo-arm added a child revision: D76084: [Sema][SVE] Reject subscripts on pointers to sizeless types.
The SVE ACLE doesn't allow arrays of sizeless types. At the moment
clang accepts the TU:
__SVInt8_t x[2];
but trying to code-generate it triggers the LLVM assertion:
llvm/lib/IR/Type.cpp:588: static llvm::ArrayType* llvm::ArrayType::get(llvm::Type*, uint64_t): Assertion `isValidElementType(ElementType) && "Invalid type for array element!"' failed.
This patch reports an appropriate error instead.
The rules are slightly more restrictive than for general incomplete types.
For example:
struct s;
typedef struct s arr[2];
is valid as far as it goes, whereas arrays of sizeless types are
invalid in all contexts. BuildArrayType therefore needs a specific
check for isSizelessType in addition to the usual handling of
incomplete types.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D76082
Files:
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaType.cpp
clang/test/Sema/sizeless-1.c
clang/test/SemaCXX/sizeless-1.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76082.249995.patch
Type: text/x-patch
Size: 7126 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200312/85a51e39/attachment.bin>
More information about the cfe-commits
mailing list