Skip to content
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
1 change: 1 addition & 0 deletions regression/goto-instrument/chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ elif echo $args | grep -q -- "--dump-c-type-header" ; then
cat "${name}-mod.gb"
mv "${name}.gb" "${name}-mod.gb"
elif echo $args | grep -q -- "--dump-c" ; then
cat "${name}-mod.gb"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this going to cause issues with other tests / increase the amount of output drastically?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this output is only generated when --dump-c is included in the test options, I think only very few cases (with small source files) will be affected. Thus, we should be fine.

mv "${name}-mod.gb" "${name}-mod.c"

if [[ "${is_windows}" == "true" ]]; then
Expand Down
19 changes: 19 additions & 0 deletions regression/goto-instrument/dump-decl-const/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <assert.h>

struct S
{
const int x;
const int y : 8;
const int *const p;
};

int foo()
{
return 1;
}

int main()
{
struct S s1 = {foo(), 1, 0};
assert(s1.x == 1);
}
16 changes: 16 additions & 0 deletions regression/goto-instrument/dump-decl-const/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
CORE
main.c
--dump-c
signed int x
signed int y
const signed int \*p
^[[:space:]]*s1 = \(struct S\)\{ .* \};
^EXIT=0$
^SIGNAL=0$
--
const signed int x
const signed int y
const p
--
This test demonstrates that the constness of struct members has been removed,
which is necessary as the initialisation is not performed in the declaration.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is just one of those unavoidable things as we split an initialisation into DECL and ASSIGN instructions.

2 changes: 2 additions & 0 deletions src/goto-instrument/goto_program2code.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1591,6 +1591,8 @@ void goto_program2codet::remove_const(typet &type)
++it)
remove_const(it->type());
}
else if(type.id() == ID_c_bit_field)
to_c_bit_field_type(type).subtype().remove(ID_C_constant);
}

static bool has_labels(const codet &code)
Expand Down