|| DERIVED_FROM_P (type1, type2)));
case CPTK_IS_BOUNDED_ARRAY:
- return type_code1 == ARRAY_TYPE && TYPE_DOMAIN (type1);
+ return (type_code1 == ARRAY_TYPE
+ && TYPE_DOMAIN (type1)
+ /* We don't want to report T[0] as being a bounded array type.
+ This is for compatibility with an implementation of
+ std::is_bounded_array by template argument deduction, because
+ compute_array_index_type_loc rejects a zero-size array
+ in SFINAE context. */
+ && !(TYPE_SIZE (type1) && integer_zerop (TYPE_SIZE (type1))));
case CPTK_IS_CLASS:
return NON_UNION_CLASS_TYPE_P (type1);
// { dg-do compile { target c++11 } }
+// { dg-options "" }
#define SA(X) static_assert((X),#X)
class ClassType { };
+constexpr int sz0 = 0;
+constexpr int sz2 = 2;
+
SA_TEST_CATEGORY(__is_bounded_array, int[2], true);
SA_TEST_CATEGORY(__is_bounded_array, int[], false);
+SA_TEST_CATEGORY(__is_bounded_array, int[0], false);
SA_TEST_CATEGORY(__is_bounded_array, int[2][3], true);
SA_TEST_CATEGORY(__is_bounded_array, int[][3], false);
+SA_TEST_CATEGORY(__is_bounded_array, int[0][3], false);
+SA_TEST_CATEGORY(__is_bounded_array, int[3][0], false);
SA_TEST_CATEGORY(__is_bounded_array, float*[2], true);
SA_TEST_CATEGORY(__is_bounded_array, float*[], false);
SA_TEST_CATEGORY(__is_bounded_array, float*[2][3], true);
SA_TEST_CATEGORY(__is_bounded_array, float*[][3], false);
SA_TEST_CATEGORY(__is_bounded_array, ClassType[2], true);
SA_TEST_CATEGORY(__is_bounded_array, ClassType[], false);
+SA_TEST_CATEGORY(__is_bounded_array, ClassType[0], false);
SA_TEST_CATEGORY(__is_bounded_array, ClassType[2][3], true);
SA_TEST_CATEGORY(__is_bounded_array, ClassType[][3], false);
+SA_TEST_CATEGORY(__is_bounded_array, ClassType[0][3], false);
+SA_TEST_CATEGORY(__is_bounded_array, ClassType[2][0], false);
+SA_TEST_CATEGORY(__is_bounded_array, int[sz2], true);
+SA_TEST_CATEGORY(__is_bounded_array, int[sz0], false);
SA_TEST_CATEGORY(__is_bounded_array, int(*)[2], false);
SA_TEST_CATEGORY(__is_bounded_array, int(*)[], false);
+SA_TEST_CATEGORY(__is_bounded_array, int(*)[0], false);
SA_TEST_CATEGORY(__is_bounded_array, int(&)[2], false);
+SA_TEST_CATEGORY(__is_bounded_array, int(&)[0], false);
SA_TEST_FN(__is_bounded_array, int(&)[], false);
// Sanity check.