File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -489,13 +489,33 @@ void c_typecheck_baset::typecheck_array_type(array_typet &type)
489
489
typecheck_type (type.subtype ());
490
490
491
491
// we don't allow void as subtype
492
- if (follow ( type.subtype ()) .id ()== ID_empty)
492
+ if (type.subtype ().id () == ID_empty)
493
493
{
494
494
error ().source_location =type.source_location ();
495
495
error () << " array of voids" << eom;
496
496
throw 0 ;
497
497
}
498
498
499
+ // we don't allow incomplete structs or unions as subtype
500
+ if (
501
+ follow (type.subtype ()).id () == ID_incomplete_struct ||
502
+ follow (type.subtype ()).id () == ID_incomplete_union)
503
+ {
504
+ // ISO/IEC 9899 6.7.5.2
505
+ error ().source_location = type.source_location ();
506
+ error () << " array has incomplete element type" << eom;
507
+ throw 0 ;
508
+ }
509
+
510
+ // we don't allow functions as subtype
511
+ if (type.subtype ().id () == ID_code)
512
+ {
513
+ // ISO/IEC 9899 6.7.5.2
514
+ error ().source_location = type.source_location ();
515
+ error () << " array of function element type" << eom;
516
+ throw 0 ;
517
+ }
518
+
499
519
// check size, if any
500
520
501
521
if (size.is_not_nil ())
You can’t perform that action at this time.
0 commit comments