Skip to content

Keep track of qualifiers for structs and unions #474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions regression/goto-instrument/const-struct1/test.desc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
KNOWNBUG
CORE
main.c
--show-symbol-table
^Type\.*: struct struct_tag_name$
^Type\.*: const struct struct_tag_name$
^Type\.*: const double$
^EXIT=0$
^SIGNAL=0$
Expand Down
10 changes: 10 additions & 0 deletions regression/goto-instrument/const-struct2/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

int main()
{
const struct struct_tag_name {
int x;
float y;
} my_struct_var = {.x = 1, .y = 3.15};
const double z = 4;
return 0;
}
9 changes: 9 additions & 0 deletions regression/goto-instrument/const-struct2/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CORE
main.c
--show-symbol-table
^Type\.*: const struct struct_tag_name$
^Type\.*: const double$
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
13 changes: 13 additions & 0 deletions regression/goto-instrument/const-struct3/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

struct struct_tag_name
{
int x;
float y;
};

int main()
{
const struct struct_tag_name my_struct_var = {.x = 1, .y = 3.15};
const double z = 4;
return 0;
}
9 changes: 9 additions & 0 deletions regression/goto-instrument/const-struct3/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CORE
main.c
--dump-c
^\s*const struct struct_tag_name my_struct_var
^\s*const double z
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
13 changes: 13 additions & 0 deletions regression/goto-instrument/const-union1/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

union union_tag_name
{
int x;
float y;
};

int main()
{
const union union_tag_name my_union_var = {.y = 3.15};
const double z = 4;
return 0;
}
9 changes: 9 additions & 0 deletions regression/goto-instrument/const-union1/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CORE
main.c
--show-symbol-table
^Type\.*: const union union_tag_name$
^Type\.*: const double$
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
13 changes: 13 additions & 0 deletions regression/goto-instrument/volatile-struct1/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

struct struct_tag_name
{
int x;
float y;
};

int main()
{
volatile struct struct_tag_name my_struct_var = {.x = 1, .y = 3.15};
const double z = 4;
return 0;
}
9 changes: 9 additions & 0 deletions regression/goto-instrument/volatile-struct1/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CORE
main.c
--show-symbol-table
^Type\.*: volatile struct struct_tag_name$
^Type\.*: const double$
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
2 changes: 2 additions & 0 deletions src/ansi-c/c_typecheck_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,9 @@ void c_typecheck_baset::typecheck_compound_type(struct_union_typet &type)
symbol_type.add_source_location()=type.source_location();
symbol_type.set_identifier(identifier);

c_qualifierst original_qualifiers(type);
type.swap(symbol_type);
original_qualifiers.write(type);
}

/*******************************************************************\
Expand Down