Community
Participate
Working Groups
Build Identifier: I20110613-1736 When declaring a variable with a type defined in another file (included header), the default constructor is one of the constructors returned by ICPPClassType.getConstructors(), after adding an explicit constructor to that type. Detail: I have two files //A.cpp #include "B.h" void foo(){ B b; } //B.h struct B{ }; In the context of the file A.h there is an implicit name at "b" indicating the relation to the implicit default constructor in "B". This is as expected so far. If I add an explicit non-default constructor to B, this implicit name remains: //A.cpp #include "B.h" void foo(){ B b; } //B.h struct B{ B(int i){} }; At least it remains until I rebuild the index of the project. The same behavior is observable if I query the ICPPClassType binding for the declaration specifier "B" in "A.cpp" for its constructors (by calling "getConstructors()"). The index gets updated after adding the explicit constructor to B, as it is returned by "getConstructor()" in addition to the implicit default- and copy-constructor. I cannot observe this behavior if I define "B" in "A.cpp". I'm not quite sure where the problem occurs or to fix it. Can the implicit default constructor binding be removed when adding an explicit constructor? Afaik the resolution in "ICPPClassType.getConstructors()" returns all declared and implicit constructors, perhaps it has to be filtered there. But I guess this would not solve the problem of the implicit name at "B b;" in "A.cpp". Reproducible: Always Steps to Reproduce: 1. Create header file with type definition. 2. Create source file declaring a variable using the type defined in the header file. 3. Add an explicit non-default constructor to the type in the header file. 4. Query the type binding in the variable declaration in the source file for its constructors.
Added testcase and fix: I remove the implicit flag of the method, when updating the class.
*** cdt git genie on behalf of Markus Schorn *** Bug 359376: Updating implicit ctors in index. [*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=7affbb771e8d3890e440225183954702d48c9794