Warning generation for non-static inline functions.

Hi all,

I am trying to generate a warning message when the there is a non-static
inline function in source code. For instance I have the following case.
inline int foo (int);
int main()
    int b = 2;
    int c = foo(b);
    return 0;
int foo(int a)
    return a;

I Need to add the checking (and also the warning message generation) in
ParseAST phase. I have looked into the source codes and I guess that the
checking can be placed in ../source/tools/clang/lib/Parse/Parser.cpp in
function Parser::DeclGroupPtrTy
Parser::ParseDeclarationOrFunctionDefinition(ParsingDeclSpec &DS,
AccessSpecifier AS) {} (at line ~772)
There is a "ParseDeclarationSpecifiers(DS, ParsedTemplateInfo(), AS,
DSC_top_level);" function call here. And I thing after this it is possible
to check has function inlinehint attribute and the static keyword is
specifies for the function (I am going to check that by StorageClassSpec).

Can anybody give me an advice am I right to do that here, or if there is
another better solution I will be very thankful if someone could help me
with this.


Have you considered other examples of inline functions, such as class
members that are implicitly inline:

struct foo {
  void func() { // because the function definition is within the
class, it is implicitly 'inline'

There might be a more general way to catch these cases, probably later
on in the front-end, similar to where we warn about unused (static)
functions. (look for the implementation of the unused function warning
& you should be pretty close) That's just a rough guess & by no means
strictly better/correct.

- David

Hi David,

Thank you for the response. Actually I have added the checking in that place
where I wanted to add. So there is a problem when I have the function
declaration and definition in the source file. The warning message is
generated twice. So it is not a better place where I wanted to add the
warning generation. I will look for the warning messages which you suggest.

Please feel free to add any suggestions.

Best regards,