Bug 310076 - C++ Parser does not handle gcc __attribute annotations in class declarations
Summary: C++ Parser does not handle gcc __attribute annotations in class declarations
Status: RESOLVED NOT A BUG
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (old) (show other bugs)
Version: 4.4.1
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: 4.3.0
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-14 09:57 UTC by Daniel Stöckel
Modified: 2013-03-31 00:51 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Stöckel 2012-11-14 09:57:26 UTC
I have a large code base of a library that uses __attribute((visibility ("default"))) to export the classes that should be part of the interface. KDevelop cannot handle these attributes which leads to errors in the code completion.

Though this is a compiler specific problem (MSVC uses annotations like __declspec(dllexport)) and thus not valid c++, this severely impedes the user experience.

Reproducible: Always

Steps to Reproduce:
The code below is a typical example of a class declaration we use:

class __attribute((visibility ("default"))) Foo
{
	Foo* child;
};
Actual Results:  
The code completion/parser/... cannot resolve Foo in the declaration of child as a known class.

Expected Results:  
Foo should be properly resolved, as is the case when removing the __attribute(...)

Due to the compiler specificness of the problem the __attribute(...) is usually wrapped in a macro. This macro evaluates to the needed annotation. KDevelop seems to parse the macro just fine though.
Comment 1 Milian Wolff 2012-11-21 13:17:00 UTC
Uhm isn't it __attribute__ (note the trailing two underscores)? That is actually being parsed just fine by our parser?
Comment 2 Milian Wolff 2012-11-21 13:17:42 UTC
yeah, see also: http://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html
Comment 3 Daniel Stöckel 2012-11-21 13:56:12 UTC
You are absolutely right... Interestingly GCC seems to accept __attribute((...)) just fine and there are some examples in the Documentation (man pages) where __attribute((...)) is used. Might be, that they changed the syntax some time ago and are now phasing out the support for the old version,

Oh well, changing the macro to use __attribute__((...)) fixes the problem for me. Thanks a lot! :-)
Comment 4 Aleix Pol 2013-03-31 00:51:36 UTC
Moving all the bugs from the CPP Parser. It was not well defined the difference between it and C++ Language Support and people kept reporting in both places indistinctively