c_countof_type (location_t loc, tree type)
{
enum tree_code type_code;
+ tree value;
type_code = TREE_CODE (type);
if (type_code != ARRAY_TYPE)
return error_mark_node;
}
- return array_type_nelts_top (type);
+ value = array_type_nelts_top (type);
+ /* VALUE will have the middle-end integer type sizetype.
+ However, we should really return a value of type `size_t',
+ which is just a typedef for an ordinary integer type. */
+ value = fold_convert_loc (loc, size_type_node, value);
+ return value;
}
\f
/* Handle C and C++ default attributes. */
_Static_assert (_Countof (int [3][n]) == 3);
_Static_assert (_Countof (int [n][3]) == 7); /* { dg-error "not constant" } */
}
+
+void
+type(void)
+{
+ _Generic (_Countof (w), __typeof__ (sizeof 0): 0);
+}