mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-10 17:55:39 +02:00
Bug 459844 - Pack expansion in nested template
Change-Id: I0f206c2b056f0e9ba388cb9f8e78ea331616a61f Signed-off-by: Nathan Ridge <zeratul976@hotmail.com>
This commit is contained in:
parent
d266f8656e
commit
145728cd74
3 changed files with 44 additions and 10 deletions
|
@ -7560,7 +7560,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
||||||
public void testSfinaeInNewExpressionWithDeletedConstructor_430230() throws Exception {
|
public void testSfinaeInNewExpressionWithDeletedConstructor_430230() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
// template <typename>
|
// template <typename>
|
||||||
// struct M {
|
// struct M {
|
||||||
// template <typename... Args>
|
// template <typename... Args>
|
||||||
|
@ -7869,6 +7869,41 @@ public class AST2TemplateTests extends AST2TestBase {
|
||||||
public void testVariadicTemplatesAndFunctionObjects_401479() throws Exception {
|
public void testVariadicTemplatesAndFunctionObjects_401479() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template<typename _Tp>
|
||||||
|
// _Tp declval() noexcept;
|
||||||
|
//
|
||||||
|
// template<typename _From>
|
||||||
|
// struct is_convertible {};
|
||||||
|
//
|
||||||
|
// template<typename _Signature>
|
||||||
|
// class function;
|
||||||
|
//
|
||||||
|
// template<typename _Res, typename... _ArgTypes>
|
||||||
|
// class function<_Res(_ArgTypes...)> {
|
||||||
|
// template<typename _Functor>
|
||||||
|
// using _Invoke = decltype(declval<_Functor&>()(declval<_ArgTypes>()...));
|
||||||
|
//
|
||||||
|
// public:
|
||||||
|
// template<typename _Functor, typename = typename is_convertible<_Invoke<_Functor>>::type>
|
||||||
|
// function(_Functor);
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// class A {};
|
||||||
|
//
|
||||||
|
// struct B {
|
||||||
|
// B(const char* s);
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// template <class T> void waldo(const B& response);
|
||||||
|
// template <class T> void waldo(function<T()> generator);
|
||||||
|
//
|
||||||
|
// void test() {
|
||||||
|
// waldo<A>(""); // problem on waldo
|
||||||
|
// }
|
||||||
|
public void testPackExpansionInNestedTemplate_459844() throws Exception {
|
||||||
|
parseAndCheckBindings();
|
||||||
|
}
|
||||||
|
|
||||||
// struct S {
|
// struct S {
|
||||||
// void kind();
|
// void kind();
|
||||||
|
|
|
@ -115,11 +115,11 @@ public abstract class CPPDependentEvaluation extends CPPEvaluation {
|
||||||
ICPPEvaluation origEval = subexpressions[i];
|
ICPPEvaluation origEval = subexpressions[i];
|
||||||
ICPPEvaluation newEval;
|
ICPPEvaluation newEval;
|
||||||
if (origEval instanceof EvalParameterPack) {
|
if (origEval instanceof EvalParameterPack) {
|
||||||
origEval = ((EvalParameterPack) origEval).getExpansionPattern();
|
ICPPEvaluation pattern = ((EvalParameterPack) origEval).getExpansionPattern();
|
||||||
if (origEval == null) {
|
if (pattern == null) {
|
||||||
newEval = EvalFixed.INCOMPLETE;
|
newEval = EvalFixed.INCOMPLETE;
|
||||||
} else {
|
} else {
|
||||||
int packSize = origEval.determinePackSize(tpMap);
|
int packSize = pattern.determinePackSize(tpMap);
|
||||||
if (packSize == CPPTemplates.PACK_SIZE_FAIL || packSize == CPPTemplates.PACK_SIZE_NOT_FOUND) {
|
if (packSize == CPPTemplates.PACK_SIZE_FAIL || packSize == CPPTemplates.PACK_SIZE_NOT_FOUND) {
|
||||||
newEval = EvalFixed.INCOMPLETE;
|
newEval = EvalFixed.INCOMPLETE;
|
||||||
} else if (packSize == CPPTemplates.PACK_SIZE_DEFER) {
|
} else if (packSize == CPPTemplates.PACK_SIZE_DEFER) {
|
||||||
|
@ -129,7 +129,7 @@ public abstract class CPPDependentEvaluation extends CPPEvaluation {
|
||||||
ICPPEvaluation[] newResult = new ICPPEvaluation[subexpressions.length + resultShift + shift];
|
ICPPEvaluation[] newResult = new ICPPEvaluation[subexpressions.length + resultShift + shift];
|
||||||
System.arraycopy(result, 0, newResult, 0, i + resultShift);
|
System.arraycopy(result, 0, newResult, 0, i + resultShift);
|
||||||
for (int j = 0; j < packSize; ++j) {
|
for (int j = 0; j < packSize; ++j) {
|
||||||
newEval = origEval.instantiate(tpMap, j, within, maxdepth, point);
|
newEval = pattern.instantiate(tpMap, j, within, maxdepth, point);
|
||||||
newResult[i + resultShift + j] = newEval;
|
newResult[i + resultShift + j] = newEval;
|
||||||
}
|
}
|
||||||
result = newResult;
|
result = newResult;
|
||||||
|
|
|
@ -1214,9 +1214,8 @@ public class CPPTemplates {
|
||||||
ICPPTemplateArgument origArg = args[i];
|
ICPPTemplateArgument origArg = args[i];
|
||||||
ICPPTemplateArgument newArg;
|
ICPPTemplateArgument newArg;
|
||||||
if (origArg.isPackExpansion()) {
|
if (origArg.isPackExpansion()) {
|
||||||
ICPPTemplateArgument unexpanded= origArg;
|
ICPPTemplateArgument pattern= origArg.getExpansionPattern();
|
||||||
origArg= origArg.getExpansionPattern();
|
int packSize= determinePackSize(pattern, tpMap);
|
||||||
int packSize= determinePackSize(origArg, tpMap);
|
|
||||||
if (packSize == PACK_SIZE_FAIL || packSize == PACK_SIZE_NOT_FOUND) {
|
if (packSize == PACK_SIZE_FAIL || packSize == PACK_SIZE_NOT_FOUND) {
|
||||||
throw new DOMException(new ProblemBinding(point, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, null));
|
throw new DOMException(new ProblemBinding(point, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, null));
|
||||||
} else if (packSize == PACK_SIZE_DEFER) {
|
} else if (packSize == PACK_SIZE_DEFER) {
|
||||||
|
@ -1226,11 +1225,11 @@ public class CPPTemplates {
|
||||||
ICPPTemplateArgument[] newResult= new ICPPTemplateArgument[args.length + resultShift + shift];
|
ICPPTemplateArgument[] newResult= new ICPPTemplateArgument[args.length + resultShift + shift];
|
||||||
System.arraycopy(result, 0, newResult, 0, i + resultShift);
|
System.arraycopy(result, 0, newResult, 0, i + resultShift);
|
||||||
for (int j= 0; j < packSize; j++) {
|
for (int j= 0; j < packSize; j++) {
|
||||||
newArg = instantiateArgument(origArg, tpMap, j, within, point);
|
newArg = instantiateArgument(pattern, tpMap, j, within, point);
|
||||||
if (!isValidArgument(newArg)) {
|
if (!isValidArgument(newArg)) {
|
||||||
if (strict)
|
if (strict)
|
||||||
return null;
|
return null;
|
||||||
result[i + resultShift] = unexpanded;
|
result[i + resultShift] = origArg;
|
||||||
newResult = result;
|
newResult = result;
|
||||||
shift = 0;
|
shift = 0;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue