fixed in this version of the patch.
--
Roland
----- Original Message -----
> From: "Douglas Gregor" <[email protected]>
> To: "Roland Leißa" <[email protected]>
> Cc: [email protected]
> Sent: Montag, 30. April 2012 16:57:54
> Subject: Re: [cfe-commits] bools in vector_size attribute causes crash
>
>
> On Apr 25, 2012, at 7:46 PM, Roland Leißa <[email protected]>
> wrote:
>
> > my old patch seemed to have a problem. Now I'm doing the check
> > differently.
> >
> > Is the test case OK like this?
>
> @@ -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
>
> How about just using _Bool here, so we don't have to #include
> <stdbool.h>?
>
> - Doug
>
> > --
> > 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.
> > <vector_size_bool_patch.diff>_______________________________________________
> > cfe-commits mailing list
> > [email protected]
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 3b70770..caae1e0 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..90a59ee 100644
--- a/test/Sema/builtins.c
+++ b/test/Sema/builtins.c
@@ -107,6 +107,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