aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2010-10-06 17:00:02 +0000
committerFariborz Jahanian <fjahanian@apple.com>2010-10-06 17:00:02 +0000
commit730e175910936eae49e65caea8b2ba81c67edff7 (patch)
tree20726e68a34c14e76480bc5888c946440a21189f
parenta0750768718bb5d05150641b5bba74847a21bc09 (diff)
Issue deprecated warning when typeof uses typedef
based on underlying type's deprecatedness. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115800 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaType.cpp5
-rw-r--r--test/Sema/typeof-use-deprecated.c13
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 4d1256577d..b86dce06b4 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -339,6 +339,10 @@ static QualType ConvertDeclSpecToType(Sema &TheSema,
// FIXME: Preserve type source info.
Result = TheSema.GetTypeFromParser(DS.getRepAsType());
assert(!Result.isNull() && "Didn't get a type for typeof?");
+ if (!Result->isDependentType())
+ if (const TagType *TT = Result->getAs<TagType>())
+ TheSema.DiagnoseUseOfDecl(TT->getDecl(),
+ DS.getTypeSpecTypeLoc());
// TypeQuals handled by caller.
Result = Context.getTypeOfType(Result);
break;
@@ -2213,7 +2217,6 @@ QualType Sema::BuildTypeofExprType(Expr *E) {
}
if (!E->isTypeDependent()) {
QualType T = E->getType();
- // FIXME. Issue warning for types built from deprecated types as well.
if (const TagType *TT = T->getAs<TagType>())
DiagnoseUseOfDecl(TT->getDecl(), E->getExprLoc());
}
diff --git a/test/Sema/typeof-use-deprecated.c b/test/Sema/typeof-use-deprecated.c
index 2e080bae1f..238e5019f1 100644
--- a/test/Sema/typeof-use-deprecated.c
+++ b/test/Sema/typeof-use-deprecated.c
@@ -11,3 +11,16 @@ typeof( u) z; // expected-warning {{'un' is deprecated}}
enum E{ one} __attribute__((deprecated)) e; // expected-warning {{'E' is deprecated}}
typeof( e) w; // expected-warning {{'E' is deprecated}}
+
+struct foo { int x; } __attribute__((deprecated));
+typedef struct foo bar __attribute__((deprecated));
+bar x1; // expected-warning {{'bar' is deprecated}}
+
+int main() { typeof(x1) y; } // expected-warning {{'foo' is deprecated}}
+
+struct gorf { int x; };
+typedef struct gorf T __attribute__((deprecated));
+T t; // expected-warning {{'T' is deprecated}}
+void wee() { typeof(t) y; }
+
+