[PATCH] cppduchain: Understand C-style use of struct in declarations

David Nolden david.nolden.kdevelop at art-master.de
Mon Aug 31 11:23:52 UTC 2009


Am Sonntag 30 August 2009 18:24:47 schrieb Nicolai Hähnle:
> Currently, KDevelop does not fully understand the following C-style code:
>
> void foo(struct bar * p)
> {
>   struct baz * q;
>   ...
> }
>
> Neither the "bar" nor the "baz" are recognized as uses of the corresponding
> structures. Without the struct keyword, KDevelop understands the example
> correctly, but obviously this is not an option if the code in question is
> actually C code.
>
> This is because the above "struct bar" is parsed as an
> ElaboratedTypeSpecifier instead of a SimpleTypeSpecifier, and then the
> usebuilder.cpp does different things. The attached patch is my suggestion
> for how to solve this.
>
> I've been using it for a day now without problems, but my entire knowledge
> of the codebase comes from a few hours debugging and code reading, so
> please just tell me if the patch does the Wrong Thing.
>
> cu,
> Nicolai
I guess your fix is correct. But I think this already worked at some point, 
which makes clear that this needs a unit-test, to verify that the patch works, 
and that it stays working.

See kdevelop/languages/cpp/cppduchain/tests/test_duchain.cpp, the test could 
be another compound statement within testDeclareStruct. Can you create such a 
test?

Thanks and greetings, David





More information about the KDevelop-devel mailing list