diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2010-10-06 23:12:32 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-10-06 23:12:32 +0000 |
| commit | c74073cd20452ac10c2bb6928d9bb78820d0b97d (patch) | |
| tree | 02cefe924a9279ad98259bfae932b93662f4217a /clang/lib/Sema/SemaDeclAttr.cpp | |
| parent | ea53e82c784281f7a2e342c04854b3e544457cd2 (diff) | |
| download | bcm5719-llvm-c74073cd20452ac10c2bb6928d9bb78820d0b97d.tar.gz bcm5719-llvm-c74073cd20452ac10c2bb6928d9bb78820d0b97d.zip | |
Patch for adding message to unavailable attribute.
And its documentation.
Finishes off // rdar: // 6734520.
llvm-svn: 115862
Diffstat (limited to 'clang/lib/Sema/SemaDeclAttr.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 3e1ced29a8d..e9ee50fe75c 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -929,12 +929,26 @@ static void HandleDeprecatedAttr(Decl *d, const AttributeList &Attr, Sema &S) { static void HandleUnavailableAttr(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; + int noArgs = Attr.getNumArgs(); + if (noArgs > 1) { + S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << "0 or 1"; return; } - - d->addAttr(::new (S.Context) UnavailableAttr(Attr.getLoc(), S.Context)); + // Handle the case where unavailable attribute has a text message. + StringLiteral *SE; + if (noArgs == 1) { + Expr *ArgExpr = static_cast<Expr *>(Attr.getArg(0)); + SE = dyn_cast<StringLiteral>(ArgExpr); + if (!SE) { + S.Diag(ArgExpr->getLocStart(), + diag::err_attribute_not_string) << "unavailable"; + return; + } + } + else + SE = StringLiteral::CreateEmpty(S.Context, 1); + d->addAttr(::new (S.Context) UnavailableAttr(Attr.getLoc(), S.Context, + SE->getString())); } static void HandleVisibilityAttr(Decl *d, const AttributeList &Attr, Sema &S) { |

