diff options
author | Nuno Lopes <nunoplopes@sapo.pt> | 2008-04-25 09:32:00 +0000 |
---|---|---|
committer | Nuno Lopes <nunoplopes@sapo.pt> | 2008-04-25 09:32:00 +0000 |
commit | 27ae6c6531ac13e4b316e7e0e7b7c846b61a8d15 (patch) | |
tree | 3e126611bab99f402087443c2b9112632c5abe27 /lib | |
parent | 4b443a614278e99c46cba3d53ee04546920ff165 (diff) |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Parse/AttributeList.cpp | 3 | ||||
-rw-r--r-- | lib/Sema/Sema.h | 1 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 26 |
3 files changed, 30 insertions, 0 deletions
diff --git a/lib/Parse/AttributeList.cpp b/lib/Parse/AttributeList.cpp index c764085caa..2d8de97f3c 100644 --- a/lib/Parse/AttributeList.cpp +++ b/lib/Parse/AttributeList.cpp @@ -90,6 +90,9 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) { case 15: if (!memcmp(Str, "ext_vector_type", 15)) return AT_ext_vector_type; break; + case 17: + if (!memcmp(Str, "transparent_union", 17)) return AT_transparent_union; + break; case 18: if (!memcmp(Str, "warn_unused_result", 18)) return AT_warn_unused_result; break; diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index 4b6722abc6..33d3ce4ece 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -323,6 +323,7 @@ private: void HandleFormatAttribute(Decl *d, AttributeList *rawAttr); void HandleStdCallAttribute(Decl *d, AttributeList *rawAttr); void HandleFastCallAttribute(Decl *d, AttributeList *rawAttr); + void HandleTransparentUnionAttribute(Decl *d, AttributeList *rawAttr); void WarnUndefinedMethod(SourceLocation ImpLoc, ObjCMethodDecl *method, bool &IncompleteImpl); diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index c97ecc8313..373aaceb87 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -2003,6 +2003,9 @@ void Sema::HandleDeclAttribute(Decl *New, AttributeList *Attr) { 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 @@ void Sema::HandleFormatAttribute(Decl *d, AttributeList *rawAttr) { 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) { |