[cfe-commits] r133264 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/Sema/attr-unavailable-message.c
Argyrios Kyrtzidis
akyrtzi at gmail.com
Fri Jun 17 10:28:30 PDT 2011
Author: akirtzidis
Date: Fri Jun 17 12:28:30 2011
New Revision: 133264
URL: http://llvm.org/viewvc/llvm-project?rev=133264&view=rev
Log:
Don't emit 'unavailable' errors inside an unavailable function. rdar://9623855.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/attr-unavailable-message.c
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=133264&r1=133263&r2=133264&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Jun 17 12:28:30 2011
@@ -104,18 +104,20 @@
break;
case AR_Unavailable:
- if (Message.empty()) {
- if (!UnknownObjCClass)
- Diag(Loc, diag::err_unavailable) << D->getDeclName();
- else
- Diag(Loc, diag::warn_unavailable_fwdclass_message)
- << D->getDeclName();
+ if (cast<Decl>(CurContext)->getAvailability() != AR_Unavailable) {
+ if (Message.empty()) {
+ if (!UnknownObjCClass)
+ Diag(Loc, diag::err_unavailable) << D->getDeclName();
+ else
+ Diag(Loc, diag::warn_unavailable_fwdclass_message)
+ << D->getDeclName();
+ }
+ else
+ Diag(Loc, diag::err_unavailable_message)
+ << D->getDeclName() << Message;
+ Diag(D->getLocation(), diag::note_unavailable_here)
+ << isa<FunctionDecl>(D) << false;
}
- else
- Diag(Loc, diag::err_unavailable_message)
- << D->getDeclName() << Message;
- Diag(D->getLocation(), diag::note_unavailable_here)
- << isa<FunctionDecl>(D) << false;
break;
}
Modified: cfe/trunk/test/Sema/attr-unavailable-message.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-unavailable-message.c?rev=133264&r1=133263&r2=133264&view=diff
==============================================================================
--- cfe/trunk/test/Sema/attr-unavailable-message.c (original)
+++ cfe/trunk/test/Sema/attr-unavailable-message.c Fri Jun 17 12:28:30 2011
@@ -16,3 +16,13 @@
}
char test2[__has_feature(attribute_unavailable_with_message) ? 1 : -1];
+
+// rdar://9623855
+void unavail(void) __attribute__((__unavailable__));
+void unavail(void) {
+ // No complains inside an unavailable function.
+ int ir = foo(1);
+ double dr = dfoo(1.0);
+ void (*fp)() = &bar;
+ double (*fp4)(double) = dfoo;
+}
More information about the cfe-commits
mailing list