[cfe-commits] r107296 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDeclAttr.cpp test/Sema/transparent-union.c
Douglas Gregor
dgregor at apple.com
Wed Jun 30 10:24:13 PDT 2010
Author: dgregor
Date: Wed Jun 30 12:24:13 2010
New Revision: 107296
URL: http://llvm.org/viewvc/llvm-project?rev=107296&view=rev
Log:
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.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Sema/transparent-union.c
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=107296&r1=107295&r2=107296&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jun 30 12:24:13 2010
@@ -965,8 +965,8 @@
"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">;
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=107296&r1=107295&r2=107296&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Jun 30 12:24:13 2010
@@ -1410,9 +1410,10 @@
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;
}
Modified: cfe/trunk/test/Sema/transparent-union.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/transparent-union.c?rev=107296&r1=107295&r2=107296&view=diff
==============================================================================
--- cfe/trunk/test/Sema/transparent-union.c (original)
+++ cfe/trunk/test/Sema/transparent-union.c Wed Jun 30 12:24:13 2010
@@ -38,3 +38,10 @@
} 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));
+
+
More information about the cfe-commits
mailing list