Hi,
noticed this while preparing some testcases for the library (but
probably Daniel pointed it out together with related issues some time
ago): if we don't handle separately identical types modulo
cv-qualifiers, we incorrectly return false for incomplete types.
Tested x86_64-linux.
Thanks,
Paolo.
////////////////////////
/cp
2013-12-07 Paolo Carlini <paolo.carl...@oracle.com>
* semantics.c (trait_expr_value, [CPTK_IS_BASE_OF]): Implement
the letter of 20.11.6 about Base and Derived naming the same
class type modulo cv-qualifiers.
/testsuite
2013-12-07 Paolo Carlini <paolo.carl...@oracle.com>
* g++.dg/ext/is_base_of_incomplete-2.C: New.
Index: cp/semantics.c
===================================================================
--- cp/semantics.c (revision 205782)
+++ cp/semantics.c (working copy)
@@ -7108,7 +7108,8 @@ trait_expr_value (cp_trait_kind kind, tree type1,
case CPTK_IS_BASE_OF:
return (NON_UNION_CLASS_TYPE_P (type1) && NON_UNION_CLASS_TYPE_P (type2)
- && DERIVED_FROM_P (type1, type2));
+ && (same_type_ignoring_top_level_qualifiers_p (type1, type2)
+ || DERIVED_FROM_P (type1, type2)));
case CPTK_IS_CLASS:
return (NON_UNION_CLASS_TYPE_P (type1));
Index: testsuite/g++.dg/ext/is_base_of_incomplete-2.C
===================================================================
--- testsuite/g++.dg/ext/is_base_of_incomplete-2.C (revision 0)
+++ testsuite/g++.dg/ext/is_base_of_incomplete-2.C (working copy)
@@ -0,0 +1,5 @@
+struct T;
+
+int check1[__is_base_of(T, T) ? 1 : -1];
+int check2[__is_base_of(T, const T) ? 1 : -1];
+int check3[__is_base_of(volatile T, T) ? 1 : -1];