[cfe-commits] r115713 - in /cfe/trunk: lib/Sema/SemaType.cpp test/Sema/typeof-use-deprecated.c
Fariborz Jahanian
fjahanian at apple.com
Tue Oct 5 16:24:00 PDT 2010
Author: fjahanian
Date: Tue Oct 5 18:24:00 2010
New Revision: 115713
URL: http://llvm.org/viewvc/llvm-project?rev=115713&view=rev
Log:
Issue deprecated warning when typeof uses an
expression of deprecated type.
Added:
cfe/trunk/test/Sema/typeof-use-deprecated.c
Modified:
cfe/trunk/lib/Sema/SemaType.cpp
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=115713&r1=115712&r2=115713&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Tue Oct 5 18:24:00 2010
@@ -2211,7 +2211,13 @@
return QualType();
}
}
-
+ if (!E->isTypeDependent()) {
+ QualType T = E->getType();
+ if (const RecordType *EltTy = T->getAs<RecordType>())
+ DiagnoseUseOfDecl(EltTy->getDecl(), E->getExprLoc());
+ else if (const EnumType *Enum = T->getAs<EnumType>())
+ DiagnoseUseOfDecl(Enum->getDecl(), E->getExprLoc());
+ }
return Context.getTypeOfExprType(E);
}
Added: cfe/trunk/test/Sema/typeof-use-deprecated.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/typeof-use-deprecated.c?rev=115713&view=auto
==============================================================================
--- cfe/trunk/test/Sema/typeof-use-deprecated.c (added)
+++ cfe/trunk/test/Sema/typeof-use-deprecated.c Tue Oct 5 18:24:00 2010
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+struct s { int a; } __attribute__((deprecated)) x; // expected-warning {{'s' is deprecated}}
+
+typeof(x) y; // expected-warning {{'s' is deprecated}}
+
+union un{ int a; } __attribute__((deprecated)) u; // expected-warning {{'un' is deprecated}}
+
+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}}
More information about the cfe-commits
mailing list