initial support for recognizing __transparent_union__ attributes
comments on the ML will follow

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50262 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index c97ecc8..373aace 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -2003,6 +2003,9 @@
   case AttributeList::AT_format:
     HandleFormatAttribute(New, Attr);
     break;
+  case AttributeList::AT_transparent_union:
+    HandleTransparentUnionAttribute(New, Attr);
+    break;
   default:
 #if 0
     // TODO: when we have the full set of attributes, warn about unknown ones.
@@ -2419,6 +2422,29 @@
                             Idx.getZExtValue(), FirstArg.getZExtValue()));
 }
 
+void Sema::HandleTransparentUnionAttribute(Decl *d, AttributeList *rawAttr) {
+  // check the attribute arguments.
+  if (rawAttr->getNumArgs() != 0) {
+    Diag(rawAttr->getLoc(), diag::err_attribute_wrong_number_arguments,
+         std::string("0"));
+    return;
+  }
+
+  TypeDecl *decl = dyn_cast<TypeDecl>(d);
+
+  if (!decl || !Context.getTypeDeclType(decl)->isUnionType()) {
+    Diag(rawAttr->getLoc(), diag::warn_attribute_wrong_decl_type,
+         "transparent_union", "union");
+    return;
+  }
+
+  QualType QTy = Context.getTypeDeclType(decl);
+  const RecordType *Ty = QTy->getAsUnionType();
+
+// FIXME
+// Ty->addAttr(new TransparentUnionAttr());
+}
+
 void Sema::HandleAnnotateAttribute(Decl *d, AttributeList *rawAttr) {
   // check the attribute arguments.
   if (rawAttr->getNumArgs() != 1) {