File tree 8 files changed +54
-13
lines changed 8 files changed +54
-13
lines changed Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+ #include <stdlib.h>
3
+
4
+ enum foo ;
5
+
6
+ int main (int argc , char * * argv )
7
+ {
8
+ size_t s = sizeof (enum foo );
9
+ assert (s == 0 );
10
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+
4
+ ^EXIT=6$
5
+ ^SIGNAL=0$
6
+ ^file main.c line \d+ function main: invalid application of \'sizeof\' to an incomplete type$
7
+ ^CONVERSION ERROR$
8
+ --
9
+ ^warning: ignoring
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+
4
+ ^EXIT=6$
5
+ ^SIGNAL=0$
6
+ ^file main.c line \d+ function main: invalid application of \'sizeof\' to an incomplete type$
7
+ ^CONVERSION ERROR$
8
+ --
9
+ ^warning: ignoring
Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+ #include <stdlib.h>
3
+
4
+ union foo ;
5
+
6
+ int main (int argc , char * * argv )
7
+ {
8
+ size_t s = sizeof (union foo );
9
+ assert (s == 0 );
10
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+
4
+ ^EXIT=6$
5
+ ^SIGNAL=0$
6
+ ^file main.c line \d+ function main: invalid application of \'sizeof\' to an incomplete type$
7
+ ^CONVERSION ERROR$
8
+ --
9
+ ^warning: ignoring
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -952,12 +952,15 @@ void c_typecheck_baset::typecheck_expr_sizeof(exprt &expr)
952
952
else
953
953
{
954
954
if (
955
- type.id () == ID_struct_tag &&
956
- to_struct_type (follow_tag (to_struct_tag_type (type))).is_incomplete ())
955
+ (type.id () == ID_struct_tag &&
956
+ to_struct_type (follow_tag (to_struct_tag_type (type))).is_incomplete ()) ||
957
+ (type.id () == ID_union_tag &&
958
+ to_union_type (follow_tag (to_union_tag_type (type))).is_incomplete ()) ||
959
+ (type.id () == ID_c_enum && to_c_enum_type (type).is_incomplete ()))
957
960
{
958
961
error ().source_location = expr.source_location ();
959
- error () << " calling sizeof for incomplete type: " << to_string ( type)
960
- << eom;
962
+ error () << " invalid application of \' sizeof \' to an incomplete type\n\t\' "
963
+ << to_string (type) << " \' " << eom;
961
964
throw 0 ;
962
965
}
963
966
You can’t perform that action at this time.
0 commit comments