Bug 307629 - Function pointers with parameters have incorrect type
Summary: Function pointers with parameters have incorrect type
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (old) (show other bugs)
Version: 4.3.1
Platform: Arch Linux Linux
: NOR normal
Target Milestone: 4.3.0
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-30 18:18 UTC by teemu.patana
Modified: 2013-03-31 00:54 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description teemu.patana 2012-09-30 18:18:08 UTC
A function pointer loses it's parameters when viewing the type.

It's quite annoying to use OpenGL with KDevelop because the functions are used through function pointers and the KDevelop's autocompletion popup thingie doesn't tell anything about the function's parameters. GLEW (OpenGL Wrapper library) makes things even more dirty by using macros for the functions, and then it's impossible to autocomplete the function's (=macro's) name. 

Reproducible: Always

Steps to Reproduce:
1. Create a new C++ project
2. Copy and paste this to the main function:
void (*funcptr)(int x);
funcptr(0);
3. Autocomplete funcptr and see what kind of parameters it takes (ctrl+space)
Actual Results:  
It tells that the type is void *funcptr.

Expected Results:  
It should tell the correct type for the function pointer, with it's parameters.

It seems that in GLEW the function pointers are wrapped in macros like this:
#define GLEW_GET_FUN(x) x
#define glUseProgram GLEW_GET_FUN(__glewUseProgram)

And it's not possible to autocomplete the macro "glUseProgram"
Comment 1 Milian Wolff 2013-01-28 01:03:29 UTC
Git commit 81ec5b516fb1ea21fc5344ccf71488bbdec1f649 by Milian Wolff.
Committed on 28/01/2013 at 00:52.
Pushed by mwolff into branch '4.5'.

Add basic support for typedef'ed function pointers.

Properly deduce the function type and create correct declarations
with the identifier of the sub_declaration id in cases such as:

void (*funcptr)(int x);
funcptr myFunc;
int main() {
    myFunc(0);
}
Related: bug 286208
DIGEST:

M  +20   -4    languages/cpp/cppduchain/declarationbuilder.cpp
M  +12   -4    languages/cpp/cppduchain/tests/test_duchain.cpp

http://commits.kde.org/kdevelop/81ec5b516fb1ea21fc5344ccf71488bbdec1f649
Comment 2 Aleix Pol 2013-03-31 00:54:10 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