@@ -3760,6 +3760,9 @@ diagnose_trait_expr (tree expr, tree args)
case CPTK_IS_MEMBER_FUNCTION_POINTER:
inform (loc, " %qT is not a member function pointer", t1);
break;
+ case CPTK_IS_MEMBER_OBJECT_POINTER:
+ inform (loc, " %qT is not a member object pointer", t1);
+ break;
case CPTK_IS_MEMBER_POINTER:
inform (loc, " %qT is not a member pointer", t1);
break;
@@ -73,6 +73,7 @@ DEFTRAIT_EXPR (IS_FINAL, "__is_final", 1)
DEFTRAIT_EXPR (IS_LAYOUT_COMPATIBLE, "__is_layout_compatible", 2)
DEFTRAIT_EXPR (IS_LITERAL_TYPE, "__is_literal_type", 1)
DEFTRAIT_EXPR (IS_MEMBER_FUNCTION_POINTER, "__is_member_function_pointer", 1)
+DEFTRAIT_EXPR (IS_MEMBER_OBJECT_POINTER, "__is_member_object_pointer", 1)
DEFTRAIT_EXPR (IS_MEMBER_POINTER, "__is_member_pointer", 1)
DEFTRAIT_EXPR (IS_NOTHROW_ASSIGNABLE, "__is_nothrow_assignable", 2)
DEFTRAIT_EXPR (IS_NOTHROW_CONSTRUCTIBLE, "__is_nothrow_constructible", -1)
@@ -12187,6 +12187,9 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2)
case CPTK_IS_MEMBER_FUNCTION_POINTER:
return TYPE_PTRMEMFUNC_P (type1);
+ case CPTK_IS_MEMBER_OBJECT_POINTER:
+ return TYPE_PTRMEM_P (type1) && !TYPE_PTRMEMFUNC_P (type1);
+
case CPTK_IS_MEMBER_POINTER:
return TYPE_PTRMEM_P (type1);
@@ -12400,6 +12403,7 @@ finish_trait_expr (location_t loc, cp_trait_kind kind, tree type1, tree type2)
case CPTK_IS_CONST:
case CPTK_IS_ENUM:
case CPTK_IS_MEMBER_FUNCTION_POINTER:
+ case CPTK_IS_MEMBER_OBJECT_POINTER:
case CPTK_IS_MEMBER_POINTER:
case CPTK_IS_SAME:
case CPTK_IS_SCOPED_ENUM:
@@ -98,6 +98,9 @@
#if !__has_builtin (__is_member_function_pointer)
# error "__has_builtin (__is_member_function_pointer) failed"
#endif
+#if !__has_builtin (__is_member_object_pointer)
+# error "__has_builtin (__is_member_object_pointer) failed"
+#endif
#if !__has_builtin (__is_member_pointer)
# error "__has_builtin (__is_member_pointer) failed"
#endif
new file mode 100644
@@ -0,0 +1,30 @@
+// { dg-do compile { target c++11 } }
+
+#include <testsuite_tr1.h>
+
+using namespace __gnu_test;
+
+#define SA(X) static_assert((X),#X)
+
+#define SA_TEST_NON_VOLATILE(TRAIT, TYPE, EXPECT) \
+ SA(TRAIT(TYPE) == EXPECT); \
+ SA(TRAIT(const TYPE) == EXPECT)
+
+#define SA_TEST_CATEGORY(TRAIT, TYPE, EXPECT) \
+ SA(TRAIT(TYPE) == EXPECT); \
+ SA(TRAIT(const TYPE) == EXPECT); \
+ SA(TRAIT(volatile TYPE) == EXPECT); \
+ SA(TRAIT(const volatile TYPE) == EXPECT)
+
+// Positive tests.
+SA_TEST_CATEGORY(__is_member_object_pointer, int (ClassType::*), true);
+SA_TEST_CATEGORY(__is_member_object_pointer, ClassType (ClassType::*), true);
+
+// Negative tests.
+SA_TEST_NON_VOLATILE(__is_member_object_pointer, int (ClassType::*) (int), false);
+SA_TEST_NON_VOLATILE(__is_member_object_pointer, int (ClassType::*) (float, ...), false);
+SA_TEST_NON_VOLATILE(__is_member_object_pointer, ClassType (ClassType::*) (ClassType), false);
+SA_TEST_NON_VOLATILE(__is_member_object_pointer, float (ClassType::*) (int, float, int[], int&), false);
+
+// Sanity check.
+SA_TEST_CATEGORY(__is_member_object_pointer, ClassType, false);