[PATCH] D88150: BuildVectorType with a dependent (array) type is crashing the compiler - Fix for PR-47542
Reid Kleckner via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 28 17:10:54 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGefd04721c9a2: BuildVectorType with a dependent (array) type is crashing the compiler - Fix… (authored by zahiraam, committed by rnk).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D88150/new/
https://reviews.llvm.org/D88150
Files:
clang/lib/Sema/SemaType.cpp
clang/test/SemaCXX/attr-gnu.cpp
Index: clang/test/SemaCXX/attr-gnu.cpp
===================================================================
--- clang/test/SemaCXX/attr-gnu.cpp
+++ clang/test/SemaCXX/attr-gnu.cpp
@@ -12,6 +12,13 @@
void g(int a[static [[]] 5]); // expected-error {{static array size is a C99 feature, not permitted in C++}}
+template<typename T> struct A {
+ int x[sizeof(T)] __attribute((vector_size(8))); // expected-error {{invalid vector element type 'int [sizeof(T)]'}}
+};
+
+typedef int myvect[4] __attribute__((vector_size(16))); // expected-error {{invalid vector element type 'int [4]'}}
+void foo(myvect *in, myvect *out) { (*out)[0] = (*in)[0]; }
+
namespace {
class B {
public:
Index: clang/lib/Sema/SemaType.cpp
===================================================================
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2517,9 +2517,10 @@
SourceLocation AttrLoc) {
// The base type must be integer (not Boolean or enumeration) or float, and
// can't already be a vector.
- if (!CurType->isDependentType() &&
- (!CurType->isBuiltinType() || CurType->isBooleanType() ||
- (!CurType->isIntegerType() && !CurType->isRealFloatingType()))) {
+ if ((!CurType->isDependentType() &&
+ (!CurType->isBuiltinType() || CurType->isBooleanType() ||
+ (!CurType->isIntegerType() && !CurType->isRealFloatingType()))) ||
+ CurType->isArrayType()) {
Diag(AttrLoc, diag::err_attribute_invalid_vector_type) << CurType;
return QualType();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88150.294835.patch
Type: text/x-patch
Size: 1535 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200929/a2a8294f/attachment.bin>
More information about the cfe-commits
mailing list