r190721 - vector_size cannot be applied to Booleans. Updated the semantic checking logic, as well as the comment and added a test case. Fixes PR12649

Aaron Ballman aaron at aaronballman.com
Fri Sep 13 13:43:08 PDT 2013


Author: aaronballman
Date: Fri Sep 13 15:43:08 2013
New Revision: 190721

URL: http://llvm.org/viewvc/llvm-project?rev=190721&view=rev
Log:
vector_size cannot be applied to Booleans.  Updated the semantic checking logic, as well as the comment and added a test case.  Fixes PR12649

Modified:
    cfe/trunk/lib/Sema/SemaType.cpp
    cfe/trunk/test/SemaCXX/vector.cpp

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=190721&r1=190720&r2=190721&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Fri Sep 13 15:43:08 2013
@@ -4614,8 +4614,9 @@ static void HandleVectorSizeAttr(QualTyp
     Attr.setInvalid();
     return;
   }
-  // the base type must be integer or float, and can't already be a vector.
-  if (!CurType->isBuiltinType() ||
+  // The base type must be integer (not Boolean or enumeration) or float, and
+  // can't already be a vector.
+  if (!CurType->isBuiltinType() || CurType->isBooleanType() ||
       (!CurType->isIntegerType() && !CurType->isRealFloatingType())) {
     S.Diag(Attr.getLoc(), diag::err_attribute_invalid_vector_type) << CurType;
     Attr.setInvalid();

Modified: cfe/trunk/test/SemaCXX/vector.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/vector.cpp?rev=190721&r1=190720&r2=190721&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/vector.cpp (original)
+++ cfe/trunk/test/SemaCXX/vector.cpp Fri Sep 13 15:43:08 2013
@@ -37,7 +37,7 @@ void f2_test(char16 c16, longlong16 ll16
 }
 
 // Test the conditional operator with vector types.
-void conditional(bool Cond, char16 c16, longlong16 ll16, char16_e c16e, 
+void conditional(bool Cond, char16 c16, longlong16 ll16, char16_e c16e,
                  longlong16_e ll16e) {
   // Conditional operators with the same type.
   __typeof__(Cond? c16 : c16) *c16p1 = &c16;
@@ -105,11 +105,11 @@ struct convertible_to { // expected-note
   operator T() const;
 };
 
-void test_implicit_conversions(bool Cond, char16 c16, longlong16 ll16, 
+void test_implicit_conversions(bool Cond, char16 c16, longlong16 ll16,
                                char16_e c16e, longlong16_e ll16e,
-                               convertible_to<char16> to_c16, 
-                               convertible_to<longlong16> to_ll16, 
-                               convertible_to<char16_e> to_c16e, 
+                               convertible_to<char16> to_c16,
+                               convertible_to<longlong16> to_ll16,
+                               convertible_to<char16_e> to_c16e,
                                convertible_to<longlong16_e> to_ll16e,
                                convertible_to<char16&> rto_c16,
                                convertible_to<char16_e&> rto_c16e) {
@@ -183,7 +183,7 @@ void test_implicit_conversions(bool Cond
 
   (void)(Cond? to_c16 : to_c16e);
   (void)(Cond? to_ll16e : to_ll16);
-  
+
   // These 2 are convertable with -flax-vector-conversions (default)
   (void)(Cond? to_c16 : to_ll16);
   (void)(Cond? to_c16e : to_ll16e);
@@ -282,3 +282,6 @@ void test_pseudo_dtor(fltx4 *f) {
 // PR16204
 typedef __attribute__((ext_vector_type(4))) int vi4;
 const int &reference_to_vec_element = vi4(1).x;
+
+// PR12649
+typedef bool bad __attribute__((__vector_size__(16)));  // expected-error {{invalid vector element type 'bool'}}





More information about the cfe-commits mailing list