Bug 286208 - Parser does not understand definition of function pointer in specialization
Summary: Parser does not understand definition of function pointer in specialization
Status: RESOLVED DUPLICATE of bug 288439
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (old) (show other bugs)
Version: git master
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: 4.2.3
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-09 17:38 UTC by Griwes
Modified: 2013-03-31 00:57 UTC (History)
1 user (show)

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 Griwes 2011-11-09 17:38:11 UTC
Version:           git master (using KDE 4.7.2) 
OS:                Linux

(example code in Steps to Reproduce)

When I define a function pointer type from template parameters, KDevelop complains about "unexpected token: '<'", '*' and '...', while the code compiles fine in G++ 4.6.1.

Reproducible: Always

Steps to Reproduce:
    template<typename signature>
    class Function;
    
    template<typename ret, typename... Args>
    class Function<ret (*)(Args...)> : public Rose::Tuple<ret (*)(Args...), Args...>
    {
    };
    
    template<typename c, typename ret, typename... Args>
    class Function<ret (c::*)(Args...)> : public Rose::Tuple<ret (c::*)(Args...), c, Args...>
    {
    };

Actual Results:  
"unexpected token" errors

Expected Results:  
parsing given code without an error
Comment 1 Xi Yang 2012-01-09 08:34:23 UTC
I also found this issue in kdevelop 4.23

//--------- code --------------
typedef void (*PhysicObjectCallback) (PhysicObject* self, double timestep);
PhysicObjectCallback userDynamicFunc;
//-----------------------------

If you point your mouse at "PhysicObjectCallback", it will give you the hint of "typedef void* PhysicObjectCallback", which is not correct.
Comment 2 Milian Wolff 2013-01-28 00:24:49 UTC
Griwes, could you supply a compilable minimal example and maybe even reference the proper sections of the C++ standard that explains how your code should behave?  I'll try to fix the parse error for now but couldn't understand it yet so I'm not sure whether I can fix it properly...
Comment 3 Milian Wolff 2013-01-28 00:27:48 UTC
Ah this is actually a duplicate - no?

*** This bug has been marked as a duplicate of bug 288439 ***
Comment 4 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 307629
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 5 Aleix Pol 2013-03-31 00:57:11 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