diff options
author | Chris Lattner <sabre@nondot.org> | 2009-05-13 04:00:12 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-05-13 04:00:12 +0000 |
commit | 2db15bdd945163eacfa4623fd2e32a536ed2dd3b (patch) | |
tree | dd82d51848a5e5b727c62a42938ef3d4d9d2778d | |
parent | e2f79b6a4f9114738fe50ee30eb222945d914341 (diff) |
Fix rdar://6881069, a crash on a form of vector_size that we
don't support. While it would be nice to support this eventually,
this form is not common at all (just seen in gcc testsuite) and
it might be better to model vector_size as a type attribute anyway.
For now just emit a nice error on it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71633 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 2 | ||||
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 3 | ||||
-rw-r--r-- | test/Sema/vector-init.c | 6 |
3 files changed, 10 insertions, 1 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 8cd5e42883..cb947fadf7 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -385,6 +385,8 @@ def err_typecheck_vector_not_convertable : Error< "can't convert between vector values of different size (%0 and %1)">; def err_typecheck_ext_vector_not_typedef : Error< "ext_vector_type only applies to types, not variables">; +def err_unsupported_vector_size : Error< + "unsupported type %0 for vector_size attribute, please use on typedef">; def err_ext_vector_component_exceeds_length : Error< "vector component access exceeds type %0">; def err_ext_vector_component_requires_even : Error< diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 919f28ffec..6e2cc699a7 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -207,7 +207,8 @@ static void HandleVectorSizeAttr(Decl *D, const AttributeList &Attr, Sema &S) { // vector arrays, and functions returning vectors. if (CurType->isPointerType() || CurType->isArrayType() || CurType->isFunctionType()) { - assert(0 && "HandleVector(): Complex type construction unimplemented"); + S.Diag(Attr.getLoc(), diag::err_unsupported_vector_size) << CurType; + return; /* FIXME: rebuild the type from the inside out, vectorizing the inner type. do { if (PointerType *PT = dyn_cast<PointerType>(canonType)) diff --git a/test/Sema/vector-init.c b/test/Sema/vector-init.c index d0d9cf053e..6eab32425a 100644 --- a/test/Sema/vector-init.c +++ b/test/Sema/vector-init.c @@ -15,3 +15,9 @@ float4 array2[2] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, float4 array3[2] = { {1.0, 2.0, 3.0}, 5.0, 6.0, 7.0, 8.0, 9.0 }; // expected-warning {{excess elements in array initializer}} + + +// rdar://6881069 +__attribute__((vector_size(16))) // expected-error {{unsupported type 'float (void)' for vector_size attribute, please use on typedef}} +float f1(void) { +} |