mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Bug 397828 - Error involving recursive variadic template
Change-Id: I68d1ed4c303fcaf7dd1b74438dc0673444f5fedc Reviewed-on: https://git.eclipse.org/r/9644 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
This commit is contained in:
parent
69c73ec432
commit
524777cfa8
2 changed files with 45 additions and 6 deletions
|
@ -4841,6 +4841,25 @@ public class AST2TemplateTests extends AST2TestBase {
|
||||||
ub= bh.assertNonProblem("f(h(args...) + args...)", 1);
|
ub= bh.assertNonProblem("f(h(args...) + args...)", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template <typename... Args>
|
||||||
|
// struct contains_waldo;
|
||||||
|
// template <>
|
||||||
|
// struct contains_waldo<> {
|
||||||
|
// static const bool value = false;
|
||||||
|
// };
|
||||||
|
// template <typename First, typename... Rest>
|
||||||
|
// struct contains_waldo<First, Rest...> {
|
||||||
|
// static const bool value = contains_waldo<Rest...>::value;
|
||||||
|
// };
|
||||||
|
// int main() {
|
||||||
|
// bool b1 = contains_waldo<int>::value;
|
||||||
|
// bool b2 = contains_waldo<int, int>::value;
|
||||||
|
// bool b2 = contains_waldo<int, int, int>::value;
|
||||||
|
// }
|
||||||
|
public void testRecursiveVariadicTemplate_397828() throws Exception {
|
||||||
|
parseAndCheckBindings();
|
||||||
|
}
|
||||||
|
|
||||||
// struct Test {
|
// struct Test {
|
||||||
// void Update() {}
|
// void Update() {}
|
||||||
// };
|
// };
|
||||||
|
|
|
@ -37,7 +37,6 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IQualifierType;
|
import org.eclipse.cdt.core.dom.ast.IQualifierType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||||
|
@ -607,15 +606,36 @@ public class TemplateArgumentDeduction {
|
||||||
final ICPPTemplateArgument[] p, final ICPPTemplateArgument[] a, CPPTemplateParameterMap map,
|
final ICPPTemplateArgument[] p, final ICPPTemplateArgument[] a, CPPTemplateParameterMap map,
|
||||||
IASTNode point) throws DOMException {
|
IASTNode point) throws DOMException {
|
||||||
TemplateArgumentDeduction deduct= new TemplateArgumentDeduction(pars, null, map, 0);
|
TemplateArgumentDeduction deduct= new TemplateArgumentDeduction(pars, null, map, 0);
|
||||||
final int len= a.length;
|
if (p == null) {
|
||||||
if (p == null || p.length != len) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (int j= 0; j < len; j++) {
|
boolean containsPackExpansion= false;
|
||||||
if (!deduct.fromTemplateArgument(p[j], a[j], point)) {
|
for (int j= 0; j < p.length; j++) {
|
||||||
return false;
|
if (p[j].isPackExpansion()) {
|
||||||
|
deduct = new TemplateArgumentDeduction(deduct, a.length - j);
|
||||||
|
containsPackExpansion= true;
|
||||||
|
if (j != p.length - 1) {
|
||||||
|
return false; // A pack expansion must be the last argument to the specialization.
|
||||||
|
}
|
||||||
|
ICPPTemplateArgument pattern = p[j].getExpansionPattern();
|
||||||
|
for (int i= j; i < a.length; i++) {
|
||||||
|
if (!deduct.fromTemplateArgument(pattern, a[i], point)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
deduct.incPackOffset();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
if (j >= a.length) {
|
||||||
|
return false; // Not enough arguments.
|
||||||
|
}
|
||||||
|
if (!deduct.fromTemplateArgument(p[j], a[j], point)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!containsPackExpansion && p.length < a.length)
|
||||||
|
return false; // Too many arguments.
|
||||||
return verifyDeduction(pars, map, false, point);
|
return verifyDeduction(pars, map, false, point);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue