[cfe-commits] r156825 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDecl.cpp test/SemaObjC/no-ivar-in-interface-block.m
Fariborz Jahanian
fjahanian at apple.com
Tue May 15 09:33:04 PDT 2012
Author: fjahanian
Date: Tue May 15 11:33:04 2012
New Revision: 156825
URL: http://llvm.org/viewvc/llvm-project?rev=156825&view=rev
Log:
objective-c nonfragile abi: discourage ivar declarations
in @interface by issuing warning (off by default) under
opt'ed in flag -Winterface-block-ivar. // rdar://10763173
Added:
cfe/trunk/test/SemaObjC/no-ivar-in-interface-block.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=156825&r1=156824&r2=156825&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue May 15 11:33:04 2012
@@ -3024,6 +3024,9 @@
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)">;
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=156825&r1=156824&r2=156825&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue May 15 11:33:04 2012
@@ -9540,7 +9540,11 @@
S->AddDecl(NewID);
IdResolver.AddDecl(NewID);
}
-
+
+ if (LangOpts.ObjCNonFragileABI2 &&
+ !NewID->isInvalidDecl() && isa<ObjCInterfaceDecl>(EnclosingDecl))
+ Diag(Loc, diag::warn_ivar_in_interface_block);
+
return NewID;
}
Added: cfe/trunk/test/SemaObjC/no-ivar-in-interface-block.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/no-ivar-in-interface-block.m?rev=156825&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/no-ivar-in-interface-block.m (added)
+++ cfe/trunk/test/SemaObjC/no-ivar-in-interface-block.m Tue May 15 11:33:04 2012
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Winterface-block-ivar %s
+// rdar://10763173
+
+ at 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}}
+}
+ at end
+
+ at interface I()
+{
+ int I1;
+ int I2;
+}
+ at end
+
+ at interface I()
+{
+ int I3, I4;
+}
+ at end
+
+ at implementation I
+{
+ int I5;
+ int I6;
+}
+ at end
More information about the cfe-commits
mailing list