mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Bug 489987 - Name resolution problem with static constexpr method
Change-Id: Ib1ec66f3c4d250112a606482a8c97a593fb0bfce
This commit is contained in:
parent
7f6e86085c
commit
d07b74f31a
3 changed files with 57 additions and 6 deletions
|
@ -7480,6 +7480,35 @@ public class AST2TemplateTests extends AST2TestBase {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template<bool, typename T = void>
|
||||||
|
// struct C {};
|
||||||
|
//
|
||||||
|
// template<typename T>
|
||||||
|
// struct C<true, T> {
|
||||||
|
// typedef T type;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// template <typename T>
|
||||||
|
// struct B {
|
||||||
|
// static constexpr bool b() {
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// struct A {
|
||||||
|
// template <typename T, typename = typename C<B<T>::b()>::type>
|
||||||
|
// A(T v);
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// void waldo(A p);
|
||||||
|
//
|
||||||
|
// void test(int x) {
|
||||||
|
// waldo(x);
|
||||||
|
// }
|
||||||
|
public void testConstexprMethod_489987() throws Exception {
|
||||||
|
parseAndCheckBindings();
|
||||||
|
}
|
||||||
|
|
||||||
// template <typename From>
|
// template <typename From>
|
||||||
// struct is_convertible {
|
// struct is_convertible {
|
||||||
// static char check(From);
|
// static char check(From);
|
||||||
|
|
|
@ -92,9 +92,28 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if all evaluations contained in the given array are constant expressions.
|
||||||
|
*
|
||||||
|
* @param evaluations the evaluations to check
|
||||||
|
* @param point the point of instantiation
|
||||||
|
*/
|
||||||
protected static boolean areAllConstantExpressions(ICPPEvaluation[] evaluations, IASTNode point) {
|
protected static boolean areAllConstantExpressions(ICPPEvaluation[] evaluations, IASTNode point) {
|
||||||
for (ICPPEvaluation eval : evaluations) {
|
return areAllConstantExpressions(evaluations, 0, evaluations.length, point);
|
||||||
if (!eval.isConstantExpression(point)) {
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if all evaluations contained in a range of the given array are constant expressions.
|
||||||
|
*
|
||||||
|
* @param evaluations the evaluations to check
|
||||||
|
* @param from the initial index of the range to be checked, inclusive
|
||||||
|
* @param to the final index of the range to be checked, exclusive
|
||||||
|
* @param point the point of instantiation
|
||||||
|
*/
|
||||||
|
protected static boolean areAllConstantExpressions(ICPPEvaluation[] evaluations, int from, int to,
|
||||||
|
IASTNode point) {
|
||||||
|
for (int i = from; i < to; i++) {
|
||||||
|
if (!evaluations[i].isConstantExpression(point)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,15 +217,18 @@ public class EvalFunctionCall extends CPPDependentEvaluation {
|
||||||
return this;
|
return this;
|
||||||
// If the arguments are not all constant expressions, there is
|
// If the arguments are not all constant expressions, there is
|
||||||
// no point trying to substitute them into the return expression.
|
// no point trying to substitute them into the return expression.
|
||||||
if (!areAllConstantExpressions(fArguments, context.getPoint()))
|
if (!areAllConstantExpressions(fArguments, 1, fArguments.length, context.getPoint()))
|
||||||
return this;
|
return this;
|
||||||
ICPPFunction function = getOverload(context.getPoint());
|
ICPPFunction function = getOverload(context.getPoint());
|
||||||
if (function == null) {
|
if (function == null) {
|
||||||
|
IBinding binding = null;
|
||||||
if (fArguments[0] instanceof EvalBinding) {
|
if (fArguments[0] instanceof EvalBinding) {
|
||||||
IBinding binding = ((EvalBinding) fArguments[0]).getBinding();
|
binding = ((EvalBinding) fArguments[0]).getBinding();
|
||||||
if (binding instanceof ICPPFunction)
|
} else if (fArguments[0] instanceof EvalMemberAccess) {
|
||||||
function = (ICPPFunction) binding;
|
binding = ((EvalMemberAccess) fArguments[0]).getMember();
|
||||||
}
|
}
|
||||||
|
if (binding instanceof ICPPFunction)
|
||||||
|
function = (ICPPFunction) binding;
|
||||||
}
|
}
|
||||||
if (function == null)
|
if (function == null)
|
||||||
return this;
|
return this;
|
||||||
|
|
Loading…
Add table
Reference in a new issue