Bug 141405 - "Open Declaration" failure with a template base class
Summary: "Open Declaration" failure with a template base class
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-parser (show other bugs)
Version: 3.0.1   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.0   Edit
Assignee: Doug Schaefer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-11 16:03 EDT by Cyrille Defranoux CLA
Modified: 2007-05-16 06:36 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Cyrille Defranoux CLA 2006-05-11 16:03:38 EDT
I am working on a small "Standard Make" project with about 300 source files. CDT often refuses to find declarations of members with the "Open Declaration" command. Refactoring also works hardly never. CDT functionality is unfortunately as less useful for me as a simple text editor.

I managed to write a very simple program that leads to a "Open Declaration" failure: a template class is used to make a second class be a singleton. If the static member INSTANCE is defined in .cpp, the "Open Declaration" does not work on "MyClass::mb" member. This command appears to work well on other symbols of this program.

Here are the simplest header and source file I used: this code compiles with g++ 4.0.1
 
---------main.h
#ifndef MAIN_H_
#define MAIN_H_

namespace MyNamespace
{
	class MyClass;
	template<class T> class Singleton;
}

template <class T> class MyNamespace::Singleton // If the declaration is enclosed in "namespace MyNamespace {}" CDT works well.
{
	public:
		static T *INSTANCE;
};

class MyNamespace::MyClass : public MyNamespace::Singleton<MyNamespace::MyClass>
{
	private:
		
		int mb;
		
	public:
	
		MyClass();
		~MyClass();
};

#endif /*MAIN_H_*/

-----------main.cpp
#include "main.h"

using namespace MyNamespace;

template<> MyClass *Singleton<MyClass>::INSTANCE = 0; // The problem disappear if this line is commented out.

MyClass::MyClass()
{
	this->mb = 2; // The "Open Declaration" command does not work on "mb".
}

int main()
{
}
Comment 1 Doug Schaefer CLA 2006-05-22 12:28:43 EDT
I'm not sure I'll get this fixed in time for 3.1. Hopefully soon after, though.
Comment 2 Markus Schorn CLA 2007-05-16 06:36:23 EDT
Works with 4.0, marking as fixed.