Bug 177055

Summary: CPPClassSpecialization is incomplete and wrong
Product: [Tools] CDT Reporter: Andrew Niefer <aniefer>
Component: cdt-parserAssignee: Doug Schaefer <cdtdoug>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: bryan2233
Version: 4.0Keywords: contributed
Target Milestone: 4.0 M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
proposed patch bjorn.freeman-benson: iplog+

Description Andrew Niefer CLA 2007-03-12 15:51:48 EDT
The implementation of CPPClassSpecialization is incomplete and its method getBases is wrong.  For better template handling we would want at least correct implementations of getBases, getConstructors, getConversionOperators and createDelegate.  Below are 2 examples of code where content assist fails because of the getBases.

Example 1:
class Base {
	public: int b1;
};

template <class T> class A {
	class C : public T {};
};

int main(int argc, char **argv) {
	A<Base>::C c;
	c.b[CTRL-SPACE];
}
Content assist fails for b.  c's type, A<Base>::C, is a CPPClassSpecialization.

Example 2:
class Base {
	public: int b1;
};

template <class T> class A {
};
template <> class A<Base> : public Base {
}
int main(int argc, char **argv) {
	A<Base> a;
	a.b[CTRL-SPACE];
}
a's type is the explicit specialization of the template, and is a CPPClassSpecialization.
Comment 1 Bryan Wilkinson CLA 2007-03-23 11:40:07 EDT
Created attachment 61840 [details]
proposed patch

Patch implements the required methods of CPPClassSepcialization.  Also, the behaviour of getCompositeScope() now depends on whether or not the class specialization is explicit.  If it is not explicit, the scope behaves the same way as a CPPClassInstance's scope, by specializing everything in the scope.
Comment 2 Doug Schaefer CLA 2007-03-23 15:52:55 EDT
Getting to it...
Comment 3 Doug Schaefer CLA 2007-03-23 16:05:24 EDT
Patch applied. Thanks!