Hi, >>It's a little hard to know the best approach with no idea of what kinds of rules you are talking about. However, given that....
The rules that I am talking about are the rules that will help user to write efficient code. For e.g. "Declare variables in descending order according to base type size." >>Using -W options is the right approach. I don't see any reason why -Wno-analyze-Rule=<rule number> wouldn't work. The reason I felt that above syntax wouldn't work is:- According to the first syntax, Wanalyze-Rule1, Wanalyze-Rule2 etc are considered as seperate options in c.opt file. A seperate flag in the form of Var(flag) is associated with each of them. This flag is set to 1 or 0 depending on whether "-W" or "-Wno" is passed respectively. By doing so there is no seperate case required in common_handle_option() function in c-opts.c. While checking for a particular rule, the warning will be prompted only if the flag is set. While according to the second syntax, changing the implementation to Wanalyze-rule=1 will mean that all these options come under one common option in c.opt, that is Wanalyze-rule=<rule number> . There will be no seperate flag like Var(flag) in this case. The <rule number> will be handled in common_handle_option() function using a switch case.This would mean that the flag value will be an integer depending on number of the rule and not 0/1. Hence only "-W" will work in this case and not "-Wno". If "-Wno" is to be implemented then a seperate option has to be added in c.opt file like Wno-analyze-rule=<number>. I did not find any such implementation done in c.opt file where "-Wno" is added as seperate option as "-W" by default has "-Wno" form. In the first syntax, seperate "-Wno" options are not required because "-W" by default has "-Wno" property. This property works only if value of flag is either 0 or 1. But the second syntax would change the value to an integer value starting from 1, so "-Wno" doesnt work. Please correct me if I am wrong in my understanding. Regards, Rahul Phalak KPIT Cummins InfoSystems Ltd. Pune, India ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Free download of GNU based tool-chains for Renesas' SH, H8, R8C, M16C and M32C Series. The following site also offers free technical support to its users. Visit http://www.kpitgnutools.com for details. Latest versions of KPIT GNU tools were released on June 1, 2006. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ On Jul 27, 2006, at 12:31 AM, Rahul Phalak wrote: > I want to add command line options in GCC for analyzing application > code > for a set of rules. I agree with Ian for the most part. For research and development, you will want to give your users lots of control. They will then give you feedback as to which ones are useful and why and which sets work well together. For production, you'll want to group the useful sets together and have controls for only the high level sets. We'd be most interested in the result of the research and the high level sets. We prefer names over numbers to identify the sets. "Rahul Phalak" <[EMAIL PROTECTED]> writes: Please don't send e-mail to both gcc@gcc.gnu.org and [EMAIL PROTECTED] This type of e-mail, related to the development of gcc, is appropriate for [EMAIL PROTECTED] > Approach 1: > Since these options are warning options, I intend to integrate them > with standard '-W' options of GCC. Doing so would by default give the > user provision of suppressing warning for a particular rule by using '-Wno'. > > For e.g.: > 1. If the user wants to analyze code for all rules, then he can do > that by using '-Wanalyze' option. > 2. If the user wants to analyze code for only rule 1, then he can do > that by using '-Wanalyze-Rule1' option. > 3. If the user wants to analyze code for all rules except rule 1, then > he can do that by using '-Wanalyze' option followed by > '-Wno-analyze-Rule1' option. > > This approach will add command line options equal to the number of > rules. > Kindly suggest whether adding so many options would be appropriate. > In order to avoid these many options, I would like to change the > syntax to '-Wanalyze-Rule=<rule number>'. Doing so would add only 1 > command line option but it is not possible to have similar syntax for > suppressing warning by using '-Wno-analyze-Rule=<rule number>'. > Please confirm my understanding on the same. It's a little hard to know the best approach with no idea of what kinds of rules you are talking about. However, given that.... Using -W options is the right approach. I don't see any reason why -Wno-analyze-Rule=<rule number> wouldn't work. Probably better would be -Wanalyze-all and -Wanalyze=RULE,RULE,RULE and -Wno-analyze=RULE,RULE,RULE where the rules have names. While I don't speak for all the gcc maintainers, I think it's very unlikely that we would a -Wanalyze option which took rule numbers, unless the numbers refer to a standard reference work along the lines of the -Weffc++ option. > 1. If the user wants to analyze code for all rules, then he can do > that by using 'analyze-all' option. > 2. If the user wants to analyze code for only rule 1, then he can do > that by using 'enable-analyze-rule=1' option. > 3. If the user wants to analyze code for all rules except rule 1, then > he can do that by using 'analyze-all' option followed by > 'disable-analyze-rule=1' option. You would need to make a very strong argument for adding a new kind of option to gcc. Perhaps the nature of the rules you are talking about makes this the right approach. However, based on what you've said so far, these sorts of option names would be inappropriate. Ian