mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-04 14:13:24 +02:00
Bug 446094 - Name resolution problem involving __is_base_of
This commit is contained in:
parent
03aa13f48d
commit
80ec72130b
2 changed files with 44 additions and 5 deletions
|
@ -10175,7 +10175,7 @@ public class AST2CPPTests extends AST2TestBase {
|
||||||
// template <bool> struct A {};
|
// template <bool> struct A {};
|
||||||
// template <>
|
// template <>
|
||||||
// struct A<false> {
|
// struct A<false> {
|
||||||
// typedef int type;
|
// typedef int type;
|
||||||
// };
|
// };
|
||||||
// struct S {};
|
// struct S {};
|
||||||
// const bool b = __is_base_of(S, int);
|
// const bool b = __is_base_of(S, int);
|
||||||
|
@ -10184,6 +10184,44 @@ public class AST2CPPTests extends AST2TestBase {
|
||||||
parseAndCheckBindings(getAboveComment(), CPP, true);
|
parseAndCheckBindings(getAboveComment(), CPP, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template<typename T, T v>
|
||||||
|
// struct integral_constant {
|
||||||
|
// static constexpr T value = v;
|
||||||
|
// typedef integral_constant<T, v> type;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// typedef integral_constant<bool, true> true_type;
|
||||||
|
//
|
||||||
|
// typedef integral_constant<bool, false> false_type;
|
||||||
|
//
|
||||||
|
// template<typename Base, typename Derived>
|
||||||
|
// struct is_base_of : public integral_constant<bool, __is_base_of(Base, Derived)> {};
|
||||||
|
//
|
||||||
|
// template<bool, typename T = void>
|
||||||
|
// struct enable_if {};
|
||||||
|
//
|
||||||
|
// template<typename T>
|
||||||
|
// struct enable_if<true, T> {
|
||||||
|
// typedef T type;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// template <class BaseType, class SubType>
|
||||||
|
// using EnableIfIsBaseOf =
|
||||||
|
// typename enable_if<is_base_of<BaseType, SubType>::value, int>::type;
|
||||||
|
//
|
||||||
|
// class A {};
|
||||||
|
//
|
||||||
|
// template <typename T>
|
||||||
|
// class B {};
|
||||||
|
//
|
||||||
|
// template <typename T, EnableIfIsBaseOf<A, T> = 0>
|
||||||
|
// using Waldo = B<T>;
|
||||||
|
//
|
||||||
|
// Waldo<A> c;
|
||||||
|
public void testIsBaseOf_446094() throws Exception {
|
||||||
|
parseAndCheckBindings(getAboveComment(), CPP, true);
|
||||||
|
}
|
||||||
|
|
||||||
// struct Bool { Bool(bool); };
|
// struct Bool { Bool(bool); };
|
||||||
// struct Char { Char(char); };
|
// struct Char { Char(char); };
|
||||||
// struct Short { Short(short); };
|
// struct Short { Short(short); };
|
||||||
|
|
|
@ -359,11 +359,12 @@ public class Value implements IValue {
|
||||||
case __is_base_of:
|
case __is_base_of:
|
||||||
type1 = SemanticUtil.getNestedType(type1, TDEF);
|
type1 = SemanticUtil.getNestedType(type1, TDEF);
|
||||||
type2 = SemanticUtil.getNestedType(type2, TDEF);
|
type2 = SemanticUtil.getNestedType(type2, TDEF);
|
||||||
if (type1 instanceof ICPPClassType && type2 instanceof ICPPClassType) {
|
if (type1 instanceof ICPPClassType && type2 instanceof ICPPClassType &&
|
||||||
return ClassTypeHelper.isSubclass((ICPPClassType) type2, (ICPPClassType) type1, point) ? 1 : 0;
|
(type1.isSameType(type2) ||
|
||||||
} else {
|
ClassTypeHelper.isSubclass((ICPPClassType) type2, (ICPPClassType) type1, point))) {
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
return VALUE_CANNOT_BE_DETERMINED;
|
return VALUE_CANNOT_BE_DETERMINED;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue