Skip to content

Commit 6a81087

Browse files
committed
Tests for class member using declaration naming a constructor
1 parent 62c1f68 commit 6a81087

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed

core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11781,4 +11781,116 @@ public void testRecognizeConstructorWithSemicolonAfterBody() throws Exception {
1178111781
public void testAllowAggregateInitializationInTemplateBody() throws Exception {
1178211782
parseAndCheckImplicitNameBindings();
1178311783
}
11784+
11785+
// // pattern from gdb custom allocator
11786+
// template<typename T>
11787+
// struct ConversionTraits {
11788+
// template<typename U>
11789+
// struct ConverterImpl {
11790+
// static constexpr int value = 42;
11791+
// };
11792+
// };
11793+
// template<typename T>
11794+
// struct Derived : public T {
11795+
// using T::T; // does not introduce name T, pulls constructors of T
11796+
// template<typename U>
11797+
// struct Converter {
11798+
// typedef ConversionTraits<T> traits;
11799+
// typedef typename traits::template ConverterImpl<U> conversion;
11800+
// };
11801+
// };
11802+
//
11803+
// template<typename T> class In {};
11804+
// template<typename T> class Out {};
11805+
//
11806+
// static constexpr auto conversion_value
11807+
// = Derived<In<int>>::Converter<Out<double>>::conversion::value;
11808+
public void testUsingDeclaratorPullDependentBaseConstructors() throws Exception {
11809+
parseAndCheckImplicitNameBindings();
11810+
BindingAssertionHelper helper = getAssertionHelper();
11811+
helper.assertVariableValue("conversion_value", 42);
11812+
}
11813+
11814+
// template<typename T>
11815+
// struct ConversionTraits {
11816+
// template<typename U>
11817+
// struct ConverterImpl {
11818+
// static constexpr int value = 42;
11819+
// };
11820+
// };
11821+
//
11822+
// template<int I, typename T>
11823+
// struct Derived : public Derived<I - 1, T> {
11824+
// using Base = Derived<I - 1, T>;
11825+
// using Base::Base; // does not introduce name Base, pulls constructors of Derived<I - 1, T>
11826+
// };
11827+
//
11828+
// template<typename T>
11829+
// struct Derived<-1, T> {
11830+
// template<typename U>
11831+
// struct Converter {
11832+
// typedef ConversionTraits<T> traits;
11833+
// typedef typename traits::template ConverterImpl<U> conversion;
11834+
// };
11835+
// };
11836+
//
11837+
// template<typename T> class In {};
11838+
// template<typename T> class Out {};
11839+
//
11840+
// static constexpr auto conversion_value
11841+
// = Derived<17, In<int>>::Converter<Out<double>>::conversion::value;
11842+
//
11843+
// static_assert(conversion_value == 42);
11844+
public void testUsingDeclaratorPullDependentTemplateBaseConstructors() throws Exception {
11845+
parseAndCheckImplicitNameBindings();
11846+
BindingAssertionHelper helper = getAssertionHelper();
11847+
helper.assertVariableValue("conversion_value", 42);
11848+
}
11849+
11850+
// template<typename T>
11851+
// struct ConversionTraits {
11852+
// template<typename U>
11853+
// struct ConverterImpl {
11854+
// static constexpr int value = 42;
11855+
// };
11856+
// };
11857+
//
11858+
// template<typename T>
11859+
// class DerivedInstantiator;
11860+
//
11861+
// template<int I, typename T>
11862+
// struct Derived : public Derived<I - 1, T> {
11863+
// using Base = Derived<I - 1, T>;
11864+
// using Base::Base; // does not introduce name Derived, pulls constructors of Derived<I - 1, T>
11865+
// };
11866+
//
11867+
// template<typename T>
11868+
// struct Derived<-1, DerivedInstantiator<T>> {
11869+
// template<typename U>
11870+
// struct Converter {
11871+
// typedef ConversionTraits<T> traits;
11872+
// typedef typename traits::template ConverterImpl<U> conversion;
11873+
// };
11874+
// };
11875+
//
11876+
// static constexpr int DEPTH = 17;
11877+
//
11878+
// template<typename T>
11879+
// struct DerivedInstantiator : public Derived<DEPTH, DerivedInstantiator<T>> {
11880+
// using Derived = Derived<DEPTH, DerivedInstantiator>; // name Derived now means type of direct base class, not Derived template class
11881+
// using Derived::Derived; // does not introduce name Derived, pulls constructors of Derived<I - 1, T>
11882+
// };
11883+
//
11884+
// template<typename T> class In {};
11885+
// template<typename T> class Out {};
11886+
//
11887+
// static constexpr auto conversion_value
11888+
// = DerivedInstantiator<In<int>>::Converter<Out<double>>::conversion::value;
11889+
//
11890+
// static_assert(conversion_value == 42);
11891+
public void testUsingDeclaratorPullRenamedDependentTemplateBaseConstructors() throws Exception {
11892+
parseAndCheckImplicitNameBindings();
11893+
BindingAssertionHelper helper = getAssertionHelper();
11894+
helper.assertVariableValue("conversion_value", 42);
11895+
}
1178411896
}

0 commit comments

Comments
 (0)