my old patch seemed to have a problem. Now I'm doing the check differently.
Is the test case OK like this?
--
Roland
----- Original Message -----
> From: "Chandler Carruth" <[email protected]>
> To: "Roland Leißa" <[email protected]>
> Cc: [email protected]
> Sent: Mittwoch, 25. April 2012 19:03:09
> Subject: Re: [cfe-commits] bools in vector_size attribute causes crash
>
>
>
> On Tue, Apr 24, 2012 at 5:38 PM, Roland Leißa <
> [email protected] > wrote:
>
>
> Hi all,
>
> this simple program currently causes a crash:
>
> typedef bool bxmm __attribute__ ((vector_size(16)));
> typedef float fxmm __attribute__ ((vector_size(16)));
>
> bxmm f(fxmm a, fxmm b) {
> return a < b;
> }
>
>
> The reason for this is, that actually bools are not allowed to be
> declared as gcc-vectors. (At least gcc does not allow this).
> The attached patch fixes this issue by emitting an error message when
> using bools in gcc-vectors.
>
>
>
> Test case as well please.
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 1b95f05..7002002 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -3829,7 +3829,8 @@ static void HandleVectorSizeAttr(QualType& CurType, const AttributeList &Attr,
return;
}
// the base type must be integer or float, and can't already be a vector.
- if (!CurType->isIntegerType() && !CurType->isRealFloatingType()) {
+ if (CurType->isBooleanType()
+ || (!CurType->isIntegerType() && !CurType->isRealFloatingType())) {
S.Diag(Attr.getLoc(), diag::err_attribute_invalid_vector_type) << CurType;
Attr.setInvalid();
return;
diff --git a/test/Sema/builtins.c b/test/Sema/builtins.c
index b8b0367..eb2cdf1 100644
--- a/test/Sema/builtins.c
+++ b/test/Sema/builtins.c
@@ -1,3 +1,5 @@
+#include <stdbool.h>
+
// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wno-string-plus-int -triple=i686-apple-darwin9
// This test needs to set the target because it uses __builtin_ia32_vec_ext_v4si
@@ -107,6 +109,7 @@ const int test17_n = 0;
const char test17_c[] = {1, 2, 3, 0};
const char test17_d[] = {1, 2, 3, 4};
typedef int __attribute__((vector_size(16))) IntVector;
+typedef bool __attribute__((vector_size(16))) BoolVector; // expected-error {{invalid vector element type 'bool'}}
struct Aggregate { int n; char c; };
enum Enum { EnumValue1, EnumValue2 };
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits