File tree 4 files changed +31
-4
lines changed
regression/ansi-c/Incomplete_Type1 4 files changed +31
-4
lines changed Original file line number Diff line number Diff line change
1
+ typedef struct incomplete_struct t ;
2
+
3
+ struct
4
+ {
5
+ t x ;
6
+ };
7
+
8
+ int main ()
9
+ {
10
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ incomplete_component.c
3
+
4
+ ^EXIT=(1|64)$
5
+ ^SIGNAL=0$
6
+ ^CONVERSION ERROR$
7
+ ^incomplete_component\.c:5:1: error: incomplete type not permitted here$
8
+ --
9
+ ^warning: ignoring
Original file line number Diff line number Diff line change @@ -872,8 +872,13 @@ void c_typecheck_baset::typecheck_compound_body(
872
872
struct_union_typet::componentt new_component (
873
873
declarator.get_base_name (), declaration.full_type (declarator));
874
874
875
- new_component.add_source_location ()=
876
- declarator.source_location ();
875
+ // There may be a declarator, which we use as location for
876
+ // the component. Otherwise, use location of the declaration.
877
+ const source_locationt source_location =
878
+ declarator.get_name ().empty () ? declaration.source_location ()
879
+ : declarator.source_location ();
880
+
881
+ new_component.add_source_location () = source_location;
877
882
new_component.set_pretty_name (declarator.get_base_name ());
878
883
879
884
typecheck_type (new_component.type ());
@@ -882,7 +887,7 @@ void c_typecheck_baset::typecheck_compound_body(
882
887
(new_component.type ().id ()!=ID_array ||
883
888
!to_array_type (new_component.type ()).is_incomplete ()))
884
889
{
885
- error ().source_location =new_component. type (). source_location () ;
890
+ error ().source_location = source_location;
886
891
error () << " incomplete type not permitted here" << eom;
887
892
throw 0 ;
888
893
}
Original file line number Diff line number Diff line change @@ -1634,7 +1634,8 @@ member_declaration:
1634
1634
| member_default_declaring_list ' ;'
1635
1635
| ' ;' /* empty declaration */
1636
1636
{
1637
- init ($$, ID_declaration);
1637
+ $$ =$1 ; // the ';' becomes the location of the declaration
1638
+ stack ($$).id(ID_declaration);
1638
1639
}
1639
1640
| static_assert_declaration ' ;'
1640
1641
;
@@ -1651,6 +1652,7 @@ member_default_declaring_list:
1651
1652
1652
1653
init ($$, ID_declaration);
1653
1654
to_ansi_c_declaration (stack($$)).set_is_member(true );
1655
+ stack ($$).add_source_location()=stack($2 ).source_location();
1654
1656
stack ($$).type().swap(stack($2 ));
1655
1657
PARSER.add_declarator(stack($$ ), stack($3 ));
1656
1658
}
@@ -1686,6 +1688,7 @@ member_declaring_list:
1686
1688
1687
1689
init ($$, ID_declaration);
1688
1690
to_ansi_c_declaration (stack($$)).set_is_member(true );
1691
+ stack ($$).add_source_location()=stack($2 ).source_location();
1689
1692
stack ($$).type().swap(stack($2 ));
1690
1693
PARSER.add_declarator(stack($$ ), stack($3 ));
1691
1694
}
You can’t perform that action at this time.
0 commit comments