"incomplete type before C2Y");
if (c_type_variably_modified_p (assoc.type))
- error_at (assoc.type_location,
- "%<_Generic%> association has "
- "variable length type");
+ pedwarn_c23 (assoc.type_location, OPT_Wpedantic,
+ "ISO C does not support %<_Generic%> association with "
+ "variably-modified type before C2Y");
}
if (!c_parser_require (parser, CPP_COLON, "expected %<:%>"))
_Generic (n, default: 1, default: 2); /* { dg-error "duplicate .*default.* case" } */
/* Variably-modified type not ok. */
- _Generic (n, int[n]: 0, default: 1); /* { dg-error "variable length type" } */
+ _Generic (n, int[n]: 0, default: 1); /* { dg-error "variably-modified" } */
/* Type must be complete. */
_Generic (n, struct incomplete: 0, default: 1); /* { dg-error "incomplete type" } */
_Generic (n, void: 0, default: 1); /* { dg-error "incomplete type" } */
-/* Test C2Y _Generic features: VM types still not allowed. */
+/* Test C2Y _Generic features: VM types allowed. */
/* { dg-do compile } */
/* { dg-options "-std=c2y -pedantic-errors" } */
void
f (int i)
{
- (void) _Generic (i, int : 1, int (*)[i] : 2); /* { dg-error "variable length" } */
+ (void) _Generic (i, int : 1, int (*)[i] : 2);
}
--- /dev/null
+/* Test C2Y _Generic features: VM types allowed. Warn for -Wc23-c2y-compat */
+/* { dg-do compile } */
+/* { dg-options "-std=c2y -pedantic-errors -Wc23-c2y-compat" } */
+
+void
+f (int i)
+{
+ (void) _Generic (i, int : 1, int (*)[i] : 2); /* { dg-warning "variably-modified type" } */
+}
+