Bug 307629

Summary: Function pointers with parameters have incorrect type
Product: [Applications] kdevelop Reporter: teemu.patana
Component: Language Support: CPP (old)Assignee: kdevelop-bugs-null
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 4.3.1   
Target Milestone: 4.3.0   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:

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