summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2011-09-29 18:40:01 +0000
committerFariborz Jahanian <fjahanian@apple.com>2011-09-29 18:40:01 +0000
commitd71061298cc290668b9640a6a15456ea9b3a937c (patch)
treec2b3e8f2232469f06c17c91ec751edcf1f5bc138 /clang/lib/Sema
parent196ebceb1431efd569b4ad37c5a4be0029e49047 (diff)
downloadbcm5719-llvm-d71061298cc290668b9640a6a15456ea9b3a937c.tar.gz
bcm5719-llvm-d71061298cc290668b9640a6a15456ea9b3a937c.zip
c - Enumerators may inherit the deprecated/unavailable
attributes from the enumeration type. // rdar://10201690 llvm-svn: 140800
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 2b67b4dc486..f9d34a7fa32 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -69,7 +69,8 @@ bool Sema::CanUseDecl(NamedDecl *D) {
/// referenced), false otherwise.
///
bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc,
- const ObjCInterfaceDecl *UnknownObjCClass) {
+ const ObjCInterfaceDecl *UnknownObjCClass,
+ const EnumDecl *EnumeratorEnumDecl) {
if (getLangOptions().CPlusPlus && isa<FunctionDecl>(D)) {
// If there were any diagnostics suppressed by template argument deduction,
// emit them now.
@@ -106,11 +107,12 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc,
// See if this declaration is unavailable or deprecated.
std::string Message;
- switch (D->getAvailability(&Message)) {
+ AvailabilityResult Result = D->getAvailability(&Message);
+ switch (Result) {
case AR_Available:
case AR_NotYetIntroduced:
break;
-
+
case AR_Deprecated:
EmitDeprecationWarning(D, Message, Loc, UnknownObjCClass);
break;
@@ -134,9 +136,17 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc,
}
// Warn if this is used but marked unused.
- if (D->hasAttr<UnusedAttr>())
+ if (D->hasAttr<UnusedAttr>() && !EnumeratorEnumDecl)
Diag(Loc, diag::warn_used_but_marked_unused) << D->getDeclName();
-
+ // For available enumerator, it will become unavailable/deprecated
+ // if its enum declaration is as such.
+ if (Result == AR_Available)
+ if (const EnumConstantDecl *ECD = dyn_cast<EnumConstantDecl>(D)) {
+ const DeclContext *DC = ECD->getDeclContext();
+ if (const EnumDecl *TheEnumDecl = dyn_cast<EnumDecl>(DC))
+ DiagnoseUseOfDecl(const_cast< EnumDecl *>(TheEnumDecl),
+ Loc, UnknownObjCClass, TheEnumDecl);
+ }
return false;
}
OpenPOWER on IntegriCloud