diff options
author | mrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-05-12 19:12:27 +0000 |
---|---|---|
committer | mrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-05-12 19:12:27 +0000 |
commit | cea476aa5767ee94491e76798faa8fc632fc2f15 (patch) | |
tree | 76921db62b2fa142958e02a9f051acc26c3c9cfb /gcc | |
parent | c6d185ef43296f06801f05217cf06d594883ff84 (diff) | |
download | gcc-cea476aa5767ee94491e76798faa8fc632fc2f15.tar.gz |
2014-05-12 Dimitris Papavasiliou <dpapavas@gmail.com>
* doc/invoke.texi: Document new switches -Wno-shadow-ivar,
-fno-local-ivars and -fivar-visibility.
* c-family/c.opt: Make -Wshadow also implicitly enable
-Wshadow-ivar.
testsuite:
* objc.dg/shadow-1.m: New test.
* objc.dg/shadow-2.m: New test.
* objc.dg/ivar-scope-1.m: New test.
* objc.dg/ivar-scope-2.m: New test.
* objc.dg/ivar-scope-3.m: New test.
* objc.dg/ivar-scope-4.m: New test.
* objc.dg/ivar-visibility-1.m: New test.
* objc.dg/ivar-visibility-2.m: New test.
* objc.dg/ivar-visibility-3.m: New test.
* objc.dg/ivar-visibility-4.m: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@210333 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/c-family/c.opt | 2 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 35 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 13 |
4 files changed, 51 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3b5619265ca..8f87b69c2e2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2014-05-12 Dimitris Papavasiliou <dpapavas@gmail.com> + + * doc/invoke.texi: Document new switches -Wno-shadow-ivar, + -fno-local-ivars and -fivar-visibility. + * c-family/c.opt: Make -Wshadow also implicitly enable + -Wshadow-ivar. + 2014-05-12 David Wohlferd <dw@LimeGreenSocks.com> * doc/tm.texi: Remove reference to deleted macro. diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 7aa9e23c10e..c586e659e0f 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -690,7 +690,7 @@ ObjC ObjC++ Var(warn_selector) Warning Warn if a selector has multiple methods Wshadow-ivar -ObjC ObjC++ Var(warn_shadow_ivar) Init(1) Warning +ObjC ObjC++ Var(warn_shadow_ivar) EnabledBy(Wshadow) Init(1) Warning Warn if a local declaration hides an instance variable Wsequence-point diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 3fe9d5f302c..da9694cbe7a 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -216,6 +216,8 @@ Objective-C and Objective-C++ Dialects}. -fobjc-gc @gol -fobjc-nilcheck @gol -fobjc-std=objc1 @gol +-fno-local-ivars @gol +-fivar-visibility=@var{public|protected|private|package} @gol -freplace-objc-classes @gol -fzero-link @gol -gen-decls @gol @@ -262,7 +264,7 @@ Objective-C and Objective-C++ Dialects}. -Wparentheses -Wpedantic-ms-format -Wno-pedantic-ms-format @gol -Wpointer-arith -Wno-pointer-to-int-cast @gol -Wredundant-decls -Wno-return-local-addr @gol --Wreturn-type -Wsequence-point -Wshadow @gol +-Wreturn-type -Wsequence-point -Wshadow -Wno-shadow-ivar @gol -Wsign-compare -Wsign-conversion -Wfloat-conversion @gol -Wsizeof-pointer-memaccess @gol -Wstack-protector -Wstack-usage=@var{len} -Wstrict-aliasing @gol @@ -2977,6 +2979,22 @@ for individual class implementations to be modified during program execution. The GNU runtime currently always retains calls to @code{objc_get_class("@dots{}")} regardless of command-line options. +@item -fno-local-ivars +@opindex fno-local-ivars +@opindex flocal-ivars +By default instance variables in Objective-C can be accessed as if +they were local variables from within the methods of the class they're +declared in. This can lead to shadowing between instance variables +and other variables declared either locally inside a class method or +globally with the same name. Specifying the @option{-fno-local-ivars} +flag disables this behavior thus avoiding variable shadowing issues. + +@item -fivar-visibility=@var{public|protected|private|package} +@opindex fivar-visibility +Set the default instance variable visibility to the specified option +so that instance variables declared outside the scope of any access +modifier directives default to the specified visibility. + @item -gen-decls @opindex gen-decls Dump interface declarations for all classes seen in the source file to a @@ -4360,10 +4378,17 @@ Do not warn whenever an @samp{#else} or an @samp{#endif} are followed by text. @item -Wshadow @opindex Wshadow @opindex Wno-shadow -Warn whenever a local variable or type declaration shadows another variable, -parameter, type, or class member (in C++), or whenever a built-in function -is shadowed. Note that in C++, the compiler warns if a local variable -shadows an explicit typedef, but not if it shadows a struct/class/enum. +Warn whenever a local variable or type declaration shadows another +variable, parameter, type, class member (in C++), or instance variable +(in Objective-C) or whenever a built-in function is shadowed. Note +that in C++, the compiler warns if a local variable shadows an +explicit typedef, but not if it shadows a struct/class/enum. + +@item -Wno-shadow-ivar @r{(Objective-C only)} +@opindex Wno-shadow-ivar +@opindex Wshadow-ivar +Do not warn whenever a local variable shadows an instance variable in an +Objective-C method. @item -Wlarger-than=@var{len} @opindex Wlarger-than=@var{len} diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a73f1f5d8fd..1bd84cfd9f1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,16 @@ +2014-05-12 Dimitris Papavasiliou <dpapavas@gmail.com> + + * objc.dg/shadow-1.m: New test. + * objc.dg/shadow-2.m: New test. + * objc.dg/ivar-scope-1.m: New test. + * objc.dg/ivar-scope-2.m: New test. + * objc.dg/ivar-scope-3.m: New test. + * objc.dg/ivar-scope-4.m: New test. + * objc.dg/ivar-visibility-1.m: New test. + * objc.dg/ivar-visibility-2.m: New test. + * objc.dg/ivar-visibility-3.m: New test. + * objc.dg/ivar-visibility-4.m: New test. + 2014-05-12 Tobias Burnus <burnus@net-b.de> PR fortran/60127 |