]> granicus.if.org Git - clang/commitdiff
Check for deprecated/unavailable/etc attributes on fields that are
authorDouglas Gregor <dgregor@apple.com>
Wed, 29 Jun 2011 21:51:31 +0000 (21:51 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 29 Jun 2011 21:51:31 +0000 (21:51 +0000)
initialized via initializer lists. Fixes <rdar://problem/9694686>.

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

lib/Sema/SemaInit.cpp
test/Sema/attr-deprecated.c

index da20e0e8fde10937970c530a14117e57317425b4..58565af9cee4745cd7c098524f7fde3f7e824529 100644 (file)
@@ -1184,6 +1184,15 @@ void InitListChecker::CheckStructUnionTypes(const InitializedEntity &Entity,
       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 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity,
       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);
 
index b26171b86b0adcc26038a1bd192289497e217237..eeef0d757a700f2204120028eae9f26a44a98e9b 100644 (file)
@@ -37,6 +37,8 @@ struct foo {
 
 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));