1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 01:15:29 +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:
Nathan Ridge 2015-02-13 03:00:45 -05:00
parent d266f8656e
commit 145728cd74
3 changed files with 44 additions and 10 deletions

View file

@ -7560,7 +7560,7 @@ public class AST2TemplateTests extends AST2TestBase {
public void testSfinaeInNewExpressionWithDeletedConstructor_430230() throws Exception {
parseAndCheckBindings();
}
// template <typename>
// struct M {
// template <typename... Args>
@ -7869,6 +7869,41 @@ public class AST2TemplateTests extends AST2TestBase {
public void testVariadicTemplatesAndFunctionObjects_401479() throws Exception {
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 {
// void kind();

View file

@ -115,11 +115,11 @@ public abstract class CPPDependentEvaluation extends CPPEvaluation {
ICPPEvaluation origEval = subexpressions[i];
ICPPEvaluation newEval;
if (origEval instanceof EvalParameterPack) {
origEval = ((EvalParameterPack) origEval).getExpansionPattern();
if (origEval == null) {
ICPPEvaluation pattern = ((EvalParameterPack) origEval).getExpansionPattern();
if (pattern == null) {
newEval = EvalFixed.INCOMPLETE;
} else {
int packSize = origEval.determinePackSize(tpMap);
int packSize = pattern.determinePackSize(tpMap);
if (packSize == CPPTemplates.PACK_SIZE_FAIL || packSize == CPPTemplates.PACK_SIZE_NOT_FOUND) {
newEval = EvalFixed.INCOMPLETE;
} 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];
System.arraycopy(result, 0, newResult, 0, i + resultShift);
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;
}
result = newResult;

View file

@ -1214,9 +1214,8 @@ public class CPPTemplates {
ICPPTemplateArgument origArg = args[i];
ICPPTemplateArgument newArg;
if (origArg.isPackExpansion()) {
ICPPTemplateArgument unexpanded= origArg;
origArg= origArg.getExpansionPattern();
int packSize= determinePackSize(origArg, tpMap);
ICPPTemplateArgument pattern= origArg.getExpansionPattern();
int packSize= determinePackSize(pattern, tpMap);
if (packSize == PACK_SIZE_FAIL || packSize == PACK_SIZE_NOT_FOUND) {
throw new DOMException(new ProblemBinding(point, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, null));
} else if (packSize == PACK_SIZE_DEFER) {
@ -1226,11 +1225,11 @@ public class CPPTemplates {
ICPPTemplateArgument[] newResult= new ICPPTemplateArgument[args.length + resultShift + shift];
System.arraycopy(result, 0, newResult, 0, i + resultShift);
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 (strict)
return null;
result[i + resultShift] = unexpanded;
result[i + resultShift] = origArg;
newResult = result;
shift = 0;
break;