1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 18:26:01 +02:00

Bug 495091 - Name resolution problem with bool() operator

Change-Id: I764c2f6887321f3dee7668550705b517460c152d
This commit is contained in:
Sergey Prigogin 2016-06-07 14:38:50 -07:00
parent 54252787ba
commit 11de0ed6b6
2 changed files with 108 additions and 67 deletions

View file

@ -3209,6 +3209,58 @@ public class AST2TemplateTests extends AST2TestBase {
ba.assertNonProblem("test=", 4, ICPPField.class); ba.assertNonProblem("test=", 4, ICPPField.class);
} }
// template<typename T, typename U>
// struct is_same {};
//
// template<typename T>
// struct is_same<T, T> {
// constexpr operator bool() { return true; }
// };
//
// template<bool>
// struct enable_if {};
//
// template<>
// struct enable_if<true> {
// typedef void type;
// };
//
// template <typename T>
// typename enable_if<is_same<T, T>{}>::type waldo(T p);
//
// void test() {
// waldo(1);
// }
public void testIntegralConversionOperator_495091a() throws Exception {
parseAndCheckBindings();
}
// template<typename T, typename U>
// struct is_same {};
//
// template<typename T>
// struct is_same<T, T> {
// constexpr operator bool() { return true; }
// };
//
// template<bool>
// struct enable_if {};
//
// template<>
// struct enable_if<true> {
// typedef void type;
// };
//
// template <typename T>
// typename enable_if<is_same<T, T>{} && true>::type waldo(T p);
//
// void test() {
// waldo(1);
// }
public void testIntegralConversionOperator_495091b() throws Exception {
parseAndCheckBindings();
}
// class A { // class A {
// public: // public:
// A(const A& a) {} // A(const A& a) {}
@ -9448,30 +9500,4 @@ public class AST2TemplateTests extends AST2TestBase {
public void testDisambiguationInNoexceptSpecifier_467332() throws Exception { public void testDisambiguationInNoexceptSpecifier_467332() throws Exception {
parseAndCheckBindings(); parseAndCheckBindings();
} }
// template<typename T, typename U>
// struct is_same {};
//
// template<typename T>
// struct is_same<T, T> {
// constexpr operator bool() { return true; }
// };
//
// template<bool>
// struct enable_if {};
//
// template<>
// struct enable_if<true> {
// typedef void type;
// };
//
// template <typename T>
// typename enable_if<is_same<T, T>{}>::type waldo(T p);
//
// void test() {
// waldo(1);
// }
public void testListInitialization_495091() throws Exception {
parseAndCheckBindings();
}
} }

View file

@ -63,6 +63,7 @@ import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArithmeticConversion; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArithmeticConversion;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPImplicitFunction;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext; import org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext;
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator; import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
@ -135,15 +136,29 @@ public class EvalBinary extends CPPDependentEvaluation {
@Override @Override
public IValue getValue(IASTNode point) { public IValue getValue(IASTNode point) {
if (getOverload(point) != null) { ICPPEvaluation arg1 = fArg1;
// TODO(sprigogin): Simulate execution of a function call. ICPPEvaluation arg2 = fArg2;
return Value.create(this); ICPPFunction overload = getOverload(point);
if (overload != null) {
ICPPFunctionType functionType = overload.getType();
IType[] parameterTypes = functionType.getParameterTypes();
arg1 = maybeApplyConversion(fArg1, parameterTypes[0], point);
arg2 = maybeApplyConversion(fArg1, parameterTypes[1], point);
if (!(overload instanceof CPPImplicitFunction)) {
if (!overload.isConstexpr())
return Value.ERROR;
ICPPEvaluation eval = new EvalBinding(overload, null, (IBinding) null);
ICPPEvaluation call =
new EvalFunctionCall(new ICPPEvaluation[] {eval, arg1, arg2}, (IBinding) null);
return call.getValue(point);
}
} }
IValue v1 = fArg1.getValue(point); IValue v1 = arg1.getValue(point);
if (v1 == null || v1 == Value.UNKNOWN) if (v1 == null || v1 == Value.UNKNOWN)
return Value.UNKNOWN; return Value.UNKNOWN;
IValue v2 = fArg2.getValue(point); IValue v2 = arg2.getValue(point);
if (v2 == null || v2 == Value.UNKNOWN) if (v2 == null || v2 == Value.UNKNOWN)
return Value.UNKNOWN; return Value.UNKNOWN;