in @interface by issuing warning (off by default) under
opt'ed in flag -Winterface-block-ivar. // rdar://
10763173
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156825
91177308-0d34-0410-b5e6-
96231b3b80d8
def err_duplicate_member : Error<"duplicate member %0">;
def err_misplaced_ivar : Error<
"ivars may not be placed in %select{categories|class extension}0">;
+def warn_ivar_in_interface_block : Warning<
+ "declaration of ivar in the interface block is deprecated">,
+ InGroup<DiagGroup<"interface-block-ivar">>, DefaultIgnore;
def ext_enum_value_not_int : Extension<
"ISO C restricts enumerator values to range of 'int' (%0 is too "
"%select{small|large}1)">;
S->AddDecl(NewID);
IdResolver.AddDecl(NewID);
}
-
+
+ if (LangOpts.ObjCNonFragileABI2 &&
+ !NewID->isInvalidDecl() && isa<ObjCInterfaceDecl>(EnclosingDecl))
+ Diag(Loc, diag::warn_ivar_in_interface_block);
+
return NewID;
}
--- /dev/null
+// RUN: %clang_cc1 -fsyntax-only -verify -Winterface-block-ivar %s
+// rdar://10763173
+
+@interface I
+{
+ @protected int P_IVAR; // expected-warning {{declaration of ivar in the interface block is deprecated}}
+
+ @public int PU_IVAR; // expected-warning {{declaration of ivar in the interface block is deprecated}}
+
+ @private int PRV_IVAR; // expected-warning {{declaration of ivar in the interface block is deprecated}}
+}
+@end
+
+@interface I()
+{
+ int I1;
+ int I2;
+}
+@end
+
+@interface I()
+{
+ int I3, I4;
+}
+@end
+
+@implementation I
+{
+ int I5;
+ int I6;
+}
+@end