diff options
author | Dan Gohman <gohman@apple.com> | 2010-11-17 00:03:07 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-11-17 00:03:07 +0000 |
commit | 34c26300b384286c544e0b9fd45e7a3648ac79e3 (patch) | |
tree | 7f98ef6aadb62950347a7fbd14579257a8a6ac90 /lib/Sema/SemaDeclAttr.cpp | |
parent | 83ce9d4a552987d34cbd500e983db8d770232379 (diff) |
Front-end support for __attribute__((may_alias)). This is not
yet hooked up to anything yet.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119407 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclAttr.cpp')
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 439ce531e6..d66ae0a554 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -731,6 +731,22 @@ static void HandleMallocAttr(Decl *d, const AttributeList &Attr, Sema &S) { S.Diag(Attr.getLoc(), diag::warn_attribute_malloc_pointer_only); } +static void HandleMayAliasAttr(Decl *d, const AttributeList &Attr, Sema &S) { + // check the attribute arguments. + if (Attr.getNumArgs() != 0) { + S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0; + return; + } + + if (!isa<TypeDecl>(d)) { + S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) + << Attr.getName() << 2 /*variable and function*/; + return; + } + + d->addAttr(::new (S.Context) MayAliasAttr(Attr.getLoc(), S.Context)); +} + static void HandleNoReturnAttr(Decl *d, const AttributeList &Attr, Sema &S) { /* Diagnostics (if any) was emitted by Sema::ProcessFnAttr(). */ assert(Attr.isInvalid() == false); @@ -2361,6 +2377,7 @@ static void ProcessDeclAttribute(Scope *scope, Decl *D, case AttributeList::AT_hiding: HandleHidingAttr (D, Attr, S); break; case AttributeList::AT_mode: HandleModeAttr (D, Attr, S); break; case AttributeList::AT_malloc: HandleMallocAttr (D, Attr, S); break; + case AttributeList::AT_may_alias: HandleMayAliasAttr (D, Attr, S); break; case AttributeList::AT_nonnull: HandleNonNullAttr (D, Attr, S); break; case AttributeList::AT_ownership_returns: case AttributeList::AT_ownership_takes: |