1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-25 01:45:33 +02:00

Bug 546843 - Initialization from dependent argument

Create deferred functions for constructor calls with dependent
arguments.

Change-Id: I007dd4fd12c13acdcb39225b73051589f6dafad3
Signed-off-by: Hannes Vogt <hannes@havogt.de>
This commit is contained in:
Hannes Vogt 2019-04-30 22:53:43 +02:00 committed by Nathan Ridge
parent 2006e6cdf1
commit 665f47395e
2 changed files with 48 additions and 0 deletions

View file

@ -13101,4 +13101,38 @@ public class AST2CPPTests extends AST2CPPTestBase {
BindingAssertionHelper bh = getAssertionHelper();
bh.assertImplicitName("foo", 3, IProblemBinding.class);
}
// class Time {
// };
//
// template<class T>
// class Test {
// private:
// T t;
// public:
// void test() {
// Time time = t.get();
// }
// };
public void testCopyInitializationFromDependentType_546843() throws Exception {
parseAndCheckImplicitNameBindings();
}
// class Time {
// int a;
// };
//
// template<class T>
// class Test {
// private:
// T t;
// public:
// void test() {
// Time time{t.get()};
// }
// };
public void testListInitializationFromDependentType_546843() throws Exception {
parseAndCheckImplicitNameBindings();
}
}

View file

@ -3726,6 +3726,11 @@ public class CPPSemantics {
IType sourceType = evaluation.getType();
ValueCategory isLValue = evaluation.getValueCategory();
if (sourceType != null) {
if (CPPTemplates.isDependentType(sourceType)) {
IType[] tmp = { sourceType };
setTargetedFunctionsToUnknown(tmp);
return CPPDeferredFunction.createForCandidates(type.getConstructors());
}
Cost c;
if (calculateInheritanceDepth(sourceType, type) >= 0) {
c = Conversions.copyInitializationOfClass(isLValue, sourceType, type, false);
@ -3747,6 +3752,15 @@ public class CPPSemantics {
// List initialization.
ICPPEvaluation eval = ((ICPPASTInitializerClause) initializer).getEvaluation();
if (eval instanceof EvalInitList) {
if (CPPTemplates.isDependentType(eval.getType())) {
ICPPEvaluation[] clauses = ((EvalInitList) eval).getClauses();
IType[] tmp = new IType[clauses.length];
for (int i = 0; i < clauses.length; i++) {
tmp[i] = clauses[i].getType();
}
setTargetedFunctionsToUnknown(tmp);
return CPPDeferredFunction.createForCandidates(type.getConstructors());
}
Cost c = Conversions.listInitializationSequence((EvalInitList) eval, type, UDCMode.ALLOWED, true);
if (c.converts()) {
ICPPFunction f = c.getUserDefinedConversion();