]> granicus.if.org Git - clang/commitdiff
Issue deprecated warning when typeof uses typedef
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 6 Oct 2010 17:00:02 +0000 (17:00 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 6 Oct 2010 17:00:02 +0000 (17:00 +0000)
based on underlying type's deprecatedness.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115800 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaType.cpp
test/Sema/typeof-use-deprecated.c

index 4d1256577dce366df1660c91d4074c75ca1b0748..b86dce06b44952bf4b3d2de87ac7f07c14d57b8c 100644 (file)
@@ -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());
   }
index 2e080bae1f2b361dc1a723c46abd86e4690a8ba0..238e5019f1212e31ece5f9d874a305a2648a9ff0 100644 (file)
@@ -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; }
+
+