This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug objc/56044] Add dialect option to gobjc to prevent instance variables from posing as local variables inside methods.


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56044

--- Comment #4 from Dimitris Papavasiliou <dpapavas at gmail dot com> 2013-01-19 22:29:10 UTC ---
I have considered -Wshadow and this is the way I think I'll go for now because
thinking up of variable names is hard enough without having to think of
synonyms on top.  The problems with -Wshadow are that:

 1) It also disables other warnings about variable shadowing which are pretty
useful and

 2) It doesn't solve the opposite side of the problem: If you decide not to use
this instance-var-as-auto convention then if for some reason, say due to a
typo, you do use it inadvertently the compiler will not complain but silently
do something you didn't mean to do.

(BTW while researching this in hope of finding something like the requested
switch, I've found numerous other complaints and questions along the same lines
so it seems it would be useful to others as well).

Testcase attached.  Just use it with

  gcc -c autoivar.m 

Let me know if there's anything more I can do to help.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]