@@ -3714,6 +3714,9 @@ diagnose_trait_expr (tree expr, tree args)
case CPTK_IS_AGGREGATE:
inform (loc, " %qT is not an aggregate", t1);
break;
+ case CPTK_IS_ARRAY:
+ inform (loc, " %qT is not an array", t1);
+ break;
case CPTK_IS_ASSIGNABLE:
inform (loc, " %qT is not assignable from %qT", t1, t2);
break;
@@ -59,6 +59,7 @@ DEFTRAIT_EXPR (HAS_UNIQUE_OBJ_REPRESENTATIONS, "__has_unique_object_representati
DEFTRAIT_EXPR (HAS_VIRTUAL_DESTRUCTOR, "__has_virtual_destructor", 1)
DEFTRAIT_EXPR (IS_ABSTRACT, "__is_abstract", 1)
DEFTRAIT_EXPR (IS_AGGREGATE, "__is_aggregate", 1)
+DEFTRAIT_EXPR (IS_ARRAY, "__is_array", 1)
DEFTRAIT_EXPR (IS_ASSIGNABLE, "__is_assignable", 2)
DEFTRAIT_EXPR (IS_BASE_OF, "__is_base_of", 2)
DEFTRAIT_EXPR (IS_CLASS, "__is_class", 1)
@@ -12143,6 +12143,9 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2)
case CPTK_IS_AGGREGATE:
return CP_AGGREGATE_TYPE_P (type1);
+ case CPTK_IS_ARRAY:
+ return type_code1 == ARRAY_TYPE;
+
case CPTK_IS_ASSIGNABLE:
return is_xible (MODIFY_EXPR, type1, type2);
@@ -12376,6 +12379,7 @@ finish_trait_expr (location_t loc, cp_trait_kind kind, tree type1, tree type2)
return error_mark_node;
break;
+ case CPTK_IS_ARRAY:
case CPTK_IS_CLASS:
case CPTK_IS_CONST:
case CPTK_IS_ENUM:
@@ -56,6 +56,9 @@
#if !__has_builtin (__is_aggregate)
# error "__has_builtin (__is_aggregate) failed"
#endif
+#if !__has_builtin (__is_array)
+# error "__has_builtin (__is_array) failed"
+#endif
#if !__has_builtin (__is_assignable)
# error "__has_builtin (__is_assignable) failed"
#endif
new file mode 100644
@@ -0,0 +1,28 @@
+// { dg-do compile { target c++11 } }
+
+#include <testsuite_tr1.h>
+
+using namespace __gnu_test;
+
+#define SA(X) static_assert((X),#X)
+#define SA_TEST_CATEGORY(TRAIT, X, expect) \
+ SA(TRAIT(X) == expect); \
+ SA(TRAIT(const X) == expect); \
+ SA(TRAIT(volatile X) == expect); \
+ SA(TRAIT(const volatile X) == expect)
+
+SA_TEST_CATEGORY(__is_array, int[2], true);
+SA_TEST_CATEGORY(__is_array, int[], true);
+SA_TEST_CATEGORY(__is_array, int[2][3], true);
+SA_TEST_CATEGORY(__is_array, int[][3], true);
+SA_TEST_CATEGORY(__is_array, float*[2], true);
+SA_TEST_CATEGORY(__is_array, float*[], true);
+SA_TEST_CATEGORY(__is_array, float*[2][3], true);
+SA_TEST_CATEGORY(__is_array, float*[][3], true);
+SA_TEST_CATEGORY(__is_array, ClassType[2], true);
+SA_TEST_CATEGORY(__is_array, ClassType[], true);
+SA_TEST_CATEGORY(__is_array, ClassType[2][3], true);
+SA_TEST_CATEGORY(__is_array, ClassType[][3], true);
+
+// Sanity check.
+SA_TEST_CATEGORY(__is_array, ClassType, false);