[cfe-commits] r134099 - in /cfe/trunk: lib/Sema/SemaInit.cpp test/Sema/attr-deprecated.c
Douglas Gregor
dgregor at apple.com
Wed Jun 29 14:51:31 PDT 2011
Author: dgregor
Date: Wed Jun 29 16:51:31 2011
New Revision: 134099
URL: http://llvm.org/viewvc/llvm-project?rev=134099&view=rev
Log:
Check for deprecated/unavailable/etc attributes on fields that are
initialized via initializer lists. Fixes <rdar://problem/9694686>.
Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/Sema/attr-deprecated.c
Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=134099&r1=134098&r2=134099&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Wed Jun 29 16:51:31 2011
@@ -1184,6 +1184,15 @@
continue;
}
+ // Make sure we can use this declaration.
+ if (SemaRef.DiagnoseUseOfDecl(*Field,
+ IList->getInit(Index)->getLocStart())) {
+ ++Index;
+ ++Field;
+ hadError = true;
+ continue;
+ }
+
InitializedEntity MemberEntity =
InitializedEntity::InitializeMember(*Field, &Entity);
CheckSubElementType(MemberEntity, IList, Field->getType(), Index,
@@ -1503,6 +1512,12 @@
StructuredList->setInitializedFieldInUnion(*Field);
}
+ // Make sure we can use this declaration.
+ if (SemaRef.DiagnoseUseOfDecl(*Field, D->getFieldLoc())) {
+ ++Index;
+ return true;
+ }
+
// Update the designator with the field declaration.
D->setField(*Field);
Modified: cfe/trunk/test/Sema/attr-deprecated.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-deprecated.c?rev=134099&r1=134098&r2=134099&view=diff
==============================================================================
--- cfe/trunk/test/Sema/attr-deprecated.c (original)
+++ cfe/trunk/test/Sema/attr-deprecated.c Wed Jun 29 16:51:31 2011
@@ -37,6 +37,8 @@
void test1(struct foo *F) {
++F->x; // expected-warning {{'x' is deprecated}}
+ struct foo f1 = { .x = 17 }; // expected-warning {{'x' is deprecated}}
+ struct foo f2 = { 17 }; // expected-warning {{'x' is deprecated}}
}
typedef struct foo foo_dep __attribute__((deprecated));
More information about the cfe-commits
mailing list