[cfe-commits] r71633 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDeclAttr.cpp test/Sema/vector-init.c

Chris Lattner sabre at nondot.org
Tue May 12 21:00:42 PDT 2009


Author: lattner
Date: Tue May 12 23:00:12 2009
New Revision: 71633

URL: http://llvm.org/viewvc/llvm-project?rev=71633&view=rev
Log:
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.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp
    cfe/trunk/test/Sema/vector-init.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=71633&r1=71632&r2=71633&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue May 12 23:00:12 2009
@@ -385,6 +385,8 @@
   "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<

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=71633&r1=71632&r2=71633&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue May 12 23:00:12 2009
@@ -207,7 +207,8 @@
   // 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))

Modified: cfe/trunk/test/Sema/vector-init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/vector-init.c?rev=71633&r1=71632&r2=71633&view=diff

==============================================================================
--- cfe/trunk/test/Sema/vector-init.c (original)
+++ cfe/trunk/test/Sema/vector-init.c Tue May 12 23:00:12 2009
@@ -15,3 +15,9 @@
 
 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) {
+}





More information about the cfe-commits mailing list