mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 519311 Handle delegating constructor in class template
- Fixed delegating constructor resolution for templated classes in ClassMembersInitializationChecker - Added a unit test for this bug Change-Id: Idb072ec05e66e0f10af53db8258459ad14f7f329 Signed-off-by: Bassem Girgis <brgirgis@gmail.com>
This commit is contained in:
parent
9c04b1bcf7
commit
ae8442fd6d
2 changed files with 22 additions and 0 deletions
|
@ -52,6 +52,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.SemanticQueries;
|
||||
import org.eclipse.cdt.core.index.IIndex;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVariableReadWriteFlags;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
||||
|
@ -291,6 +292,9 @@ public class ClassMembersInitializationChecker extends AbstractIndexAstChecker {
|
|||
} else if (memberBinding instanceof ICPPConstructor) {
|
||||
classType = ((ICPPConstructor) memberBinding).getClassOwner();
|
||||
}
|
||||
if (classType instanceof ICPPDeferredClassInstance) {
|
||||
classType = ((ICPPDeferredClassInstance) classType).getClassTemplate();
|
||||
}
|
||||
if (classType != null && classType.isSameType(constructor.getClassOwner()))
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -639,6 +639,24 @@ public class ClassMembersInitializationCheckerTest extends CheckerTestCase {
|
|||
checkNoErrors();
|
||||
}
|
||||
|
||||
// template <typename T>
|
||||
// class TemplateWithWarning {
|
||||
// public:
|
||||
// TemplateWithWarning(int number) {
|
||||
// internalNumber = number;
|
||||
// }
|
||||
//
|
||||
// TemplateWithWarning(int number, bool someFlag)
|
||||
// : TemplateWithWarning(number) {}
|
||||
//
|
||||
// protected:
|
||||
// int internalNumber;
|
||||
// };
|
||||
public void testDelegatingConstructorWithTemplate_519311() throws Exception {
|
||||
loadCodeAndRun(getAboveComment());
|
||||
checkNoErrors();
|
||||
}
|
||||
|
||||
// struct A {
|
||||
// A() {};
|
||||
// int x = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue