mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42: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();
|
||||
}
|
||||
|
||||
// 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>
|
||||
// struct is_convertible {
|
||||
// static char check(From);
|
||||
|
|
|
@ -92,9 +92,28 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
|
|||
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) {
|
||||
for (ICPPEvaluation eval : evaluations) {
|
||||
if (!eval.isConstantExpression(point)) {
|
||||
return areAllConstantExpressions(evaluations, 0, evaluations.length, 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -217,16 +217,19 @@ public class EvalFunctionCall extends CPPDependentEvaluation {
|
|||
return this;
|
||||
// If the arguments are not all constant expressions, there is
|
||||
// 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;
|
||||
ICPPFunction function = getOverload(context.getPoint());
|
||||
if (function == null) {
|
||||
IBinding binding = null;
|
||||
if (fArguments[0] instanceof EvalBinding) {
|
||||
IBinding binding = ((EvalBinding) fArguments[0]).getBinding();
|
||||
binding = ((EvalBinding) fArguments[0]).getBinding();
|
||||
} else if (fArguments[0] instanceof EvalMemberAccess) {
|
||||
binding = ((EvalMemberAccess) fArguments[0]).getMember();
|
||||
}
|
||||
if (binding instanceof ICPPFunction)
|
||||
function = (ICPPFunction) binding;
|
||||
}
|
||||
}
|
||||
if (function == null)
|
||||
return this;
|
||||
ICPPEvaluation eval = CPPFunction.getReturnExpression(function, context.getPoint());
|
||||
|
|
Loading…
Add table
Reference in a new issue