summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorNuno Lopes <nunoplopes@sapo.pt>2008-04-25 09:32:00 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2008-04-25 09:32:00 +0000
commit0276933b4bebe472ffbe89e0047da7721d4fbe6c (patch)
treee958bba1593ee44c8c464cd15dbdb56407608ec4 /clang/lib/Sema/SemaDecl.cpp
parent59834d1c7a98fc13153169188c6e3174d2c2f458 (diff)
downloadbcm5719-llvm-0276933b4bebe472ffbe89e0047da7721d4fbe6c.tar.gz
bcm5719-llvm-0276933b4bebe472ffbe89e0047da7721d4fbe6c.zip
initial support for recognizing __transparent_union__ attributes
comments on the ML will follow llvm-svn: 50262
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index c97ecc83131..373aaceb87f 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/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) {
OpenPOWER on IntegriCloud