Page MenuHomePhabricator

[Sema][SVE] Reject arrays of sizeless types

Authored by rsandifo-arm on Mar 12 2020, 11:28 AM.



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.

Diff Detail

Event Timeline

rsandifo-arm created this revision.Mar 12 2020, 11:28 AM
efriedma accepted this revision.Mar 12 2020, 12:22 PM

It might be reasonable to support this at some point, but sure, I'm fine rejecting it for now. LGTM

This revision is now accepted and ready to land.Mar 12 2020, 12:22 PM
This revision was automatically updated to reflect the committed changes.