1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Bug 446094 - Name resolution problem involving __is_base_of

This commit is contained in:
Sergey Prigogin 2014-10-06 15:51:23 -07:00
parent 03aa13f48d
commit 80ec72130b
2 changed files with 44 additions and 5 deletions

View file

@ -10175,7 +10175,7 @@ public class AST2CPPTests extends AST2TestBase {
// template <bool> struct A {};
// template <>
// struct A<false> {
// typedef int type;
// typedef int type;
// };
// struct S {};
// const bool b = __is_base_of(S, int);
@ -10184,6 +10184,44 @@ public class AST2CPPTests extends AST2TestBase {
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 Char { Char(char); };
// struct Short { Short(short); };

View file

@ -359,11 +359,12 @@ public class Value implements IValue {
case __is_base_of:
type1 = SemanticUtil.getNestedType(type1, TDEF);
type2 = SemanticUtil.getNestedType(type2, TDEF);
if (type1 instanceof ICPPClassType && type2 instanceof ICPPClassType) {
return ClassTypeHelper.isSubclass((ICPPClassType) type2, (ICPPClassType) type1, point) ? 1 : 0;
} else {
return 0;
if (type1 instanceof ICPPClassType && type2 instanceof ICPPClassType &&
(type1.isSameType(type2) ||
ClassTypeHelper.isSubclass((ICPPClassType) type2, (ICPPClassType) type1, point))) {
return 1;
}
return 0;
}
return VALUE_CANNOT_BE_DETERMINED;
}