[cfe-commits] r115800 - in /cfe/trunk: lib/Sema/SemaType.cpp test/Sema/typeof-use-deprecated.c
Fariborz Jahanian
fjahanian at apple.com
Wed Oct 6 10:00:02 PDT 2010
Author: fjahanian
Date: Wed Oct 6 12:00:02 2010
New Revision: 115800
URL: http://llvm.org/viewvc/llvm-project?rev=115800&view=rev
Log:
Issue deprecated warning when typeof uses typedef
based on underlying type's deprecatedness.
Modified:
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/Sema/typeof-use-deprecated.c
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=115800&r1=115799&r2=115800&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed Oct 6 12:00:02 2010
@@ -339,6 +339,10 @@
// 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 @@
}
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());
}
Modified: cfe/trunk/test/Sema/typeof-use-deprecated.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/typeof-use-deprecated.c?rev=115800&r1=115799&r2=115800&view=diff
==============================================================================
--- cfe/trunk/test/Sema/typeof-use-deprecated.c (original)
+++ cfe/trunk/test/Sema/typeof-use-deprecated.c Wed Oct 6 12:00:02 2010
@@ -11,3 +11,16 @@
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; }
+
+
More information about the cfe-commits
mailing list