diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-06-30 17:24:13 +0000 | 
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-06-30 17:24:13 +0000 | 
| commit | 2187266120ddf4204da821f553190d34a59b4748 (patch) | |
| tree | 3a49f50116d4845b3c9f37761ec08236d15ae2d1 | |
| parent | 945a347478b909c7805f7e157918dfc9c1b5fbad (diff) | |
| download | bcm5719-llvm-2187266120ddf4204da821f553190d34a59b4748.tar.gz bcm5719-llvm-2187266120ddf4204da821f553190d34a59b4748.zip  | |
Complain about the application of a transparent_union attribute to a
union whose first field has integral vector type. Also, clean up this
diagnostic a bit. Thanks to Eli for spotting this change in semantics
last week.
llvm-svn: 107296
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 4 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 5 | ||||
| -rw-r--r-- | clang/test/Sema/transparent-union.c | 7 | 
3 files changed, 12 insertions, 4 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 752e4da7e70..fae25196fef 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -965,8 +965,8 @@ def warn_transparent_union_attribute_not_definition : Warning<    "transparent_union attribute can only be applied to a union definition; "    "attribute ignored">;  def warn_transparent_union_attribute_floating : Warning< -  "first field of a transparent union cannot have floating point or vector " -  "type; transparent_union attribute ignored">; +  "first field of a transparent union cannot have %select{floating point|" +  "vector}0 type %1; transparent_union attribute ignored">;  def warn_transparent_union_attribute_zero_fields : Warning<    "transparent union definition must contain at least one field; "    "transparent_union attribute ignored">; diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 0f53fb92ef6..db128185f21 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -1410,9 +1410,10 @@ static void HandleTransparentUnionAttr(Decl *d, const AttributeList &Attr,    FieldDecl *FirstField = *Field;    QualType FirstType = FirstField->getType(); -  if (FirstType->hasFloatingRepresentation()) { +  if (FirstType->hasFloatingRepresentation() || FirstType->isVectorType()) {      S.Diag(FirstField->getLocation(), -           diag::warn_transparent_union_attribute_floating); +           diag::warn_transparent_union_attribute_floating) +      << FirstType->isVectorType() << FirstType;      return;    } diff --git a/clang/test/Sema/transparent-union.c b/clang/test/Sema/transparent-union.c index cdfc8506d1b..27d5c2403b4 100644 --- a/clang/test/Sema/transparent-union.c +++ b/clang/test/Sema/transparent-union.c @@ -38,3 +38,10 @@ typedef union {  } TU3 __attribute__((transparent_union));  typedef union { } TU4 __attribute__((transparent_union)); // expected-warning{{field}}  + +typedef int int4 __attribute__((ext_vector_type(4))); +typedef union { +  int4 vec; // expected-warning{{first field of a transparent union cannot have vector type 'int4'; transparent_union attribute ignored}} +} TU5 __attribute__((transparent_union)); + +    | 

