This is the mail archive of the gcc-help@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]

Re: Adding new rule into compiler


On 2018-06-06 02:02 +0800, 李宗霖 wrote:
> Hello,
> 
> I'm a gcc beginner from Taiwan.
> Nice to meet you.
> 
> I would like to add some new rule into compiler so that it can detect the
> extra error/warning.
> But I don't know which file is the one do the action.
> Can you give some advice about the relationship of gcc files?

info gccint.  Though it is quite outdated :(

Generally at first you should add an option like "Wfoo" in common.opt or other
(language specific) opt file, for e.g.:

Wfoo
Common Var(flag_warn_foo) Warning
Warn about misusage of foo.

Then you can get the value of this option from the variable flag_warn_foo in
(auto generated) options.h.

Then just implement the warning option (call warning_at to output the
diagnostic) in language FE or the middle end.

At last add a test for -Wfoo in gcc/testsuite/gcc.dg (for C) or
gcc/testsuite/g++.dg (for C++).  Now you can build modified GCC and run the
testsuite to make sure there is no regression, and -Wfoo is working properly.
-- 
Xi Ruoyao <ryxi@stu.xidian.edu.cn>
School of Aerospace Science and Technology, Xidian University

Attachment: smime.p7s
Description: S/MIME cryptographic signature


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