1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 08:55:25 +02:00

Bug 502109 - Name resolution problem with alias template

Change-Id: I1475ae9aef468f0f3075ed4a9689b15788be4d42
This commit is contained in:
Sergey Prigogin 2016-09-25 11:26:41 -07:00
parent 53ec9571cb
commit d652858b3a
2 changed files with 67 additions and 5 deletions

View file

@ -6267,7 +6267,7 @@ public class AST2TemplateTests extends AST2TestBase {
public void testTemplateIDAmbiguity_445177() throws Exception {
parseAndCheckBindings();
}
// template <bool, typename>
// struct EnableIf;
//
@ -6281,7 +6281,7 @@ public class AST2TemplateTests extends AST2TestBase {
// template <typename> struct TupleSize;
//
// template<typename... E>
// struct TupleSize<Tuple<E...>> {
// struct TupleSize<Tuple<E...>> {
// static constexpr int value = sizeof...(E);
// };
//
@ -7482,6 +7482,65 @@ public class AST2TemplateTests extends AST2TestBase {
parseAndCheckBindings();
}
// struct true_type {
// constexpr operator bool() const { return true; }
// };
//
// struct false_type {
// constexpr operator bool() const { return false; }
// };
//
// template<bool, typename T = void>
// struct enable_if {};
//
// template<typename T>
// struct enable_if<true, T> {
// typedef T type;
// };
//
// template<typename T>
// struct C {
// T* ptr();
// };
//
// struct A {};
//
// struct B {
// B(A a);
// };
//
// template<class T>
// auto ptr1(T t) -> decltype(t.ptr());
//
// template <typename T>
// struct E {
// template <typename U>
// using G = decltype(ptr1(U()));
// template <typename U>
// using H = decltype(*U());
//
// using type1 = H<G<T>>;
// };
//
// template<typename T>
// struct D {
// typedef true_type type2;
// };
//
// template <typename T>
// using F = typename D<typename E<T>::type1>::type2;
//
// template <typename T, typename = typename enable_if<F<T>{}>::type>
// void waldo(T p);
//
// void test() {
// C<A> a;
// waldo(a);
// }
public void testAliasTemplate_502109() throws Exception {
parseAndCheckBindings();
}
// template <typename T>
// struct Struct {};
//
@ -9687,7 +9746,7 @@ public class AST2TemplateTests extends AST2TestBase {
public void testBraceInitialization_490475b() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
IVariable waldo = helper.assertNonProblem("waldo");
// TODO(nathanridge):
// TODO(nathanridge):
// Actually test that we get the correct value.
// For this, we need to add support for aggregate initialization in EvalTypeId.
// For now, just test that attempting to evaluate doesn't throw an exception.

View file

@ -13,6 +13,8 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromReturnType;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCategoryFromReturnType;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
@ -30,8 +32,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.internal.core.dom.parser.CompositeValue;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.parser.CompositeValue;
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
import org.eclipse.cdt.internal.core.dom.parser.IntegralValue;
@ -77,6 +79,8 @@ public class EvalTypeId extends CPPDependentEvaluation {
if (arguments == null)
throw new NullPointerException("arguments"); //$NON-NLS-1$
if (!CPPTemplates.isDependentType(type))
type = SemanticUtil.getNestedType(type, TDEF | CVTYPE);
fInputType= type;
fArguments= arguments;
fRepresentsNewExpression = forNewExpression;
@ -179,7 +183,6 @@ public class EvalTypeId extends CPPDependentEvaluation {
default:
return IntegralValue.UNKNOWN;
}
}
}
if (fArguments.length == 1) {