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
17 changes: 17 additions & 0 deletions regression/cbmc/cprover_id1/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <assert.h>

void foo()
{
static int local;
local = 1;
}

int main()
{
// foo::1::local is the fully qualified name generated by the C front-end at
// this time. This is an implementation detail that could change at any time,
// and the test would need to be adjusted accordingly.
assert(__CPROVER_ID "foo::1::local" == 0);
foo();
assert(__CPROVER_ID "foo::1::local" == 1);
}
11 changes: 11 additions & 0 deletions regression/cbmc/cprover_id1/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CORE
main.c

^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
--
This test demonstrates the use of __CPROVER_ID to form identifier names that
would not otherwise constitute syntactically identifiers in C code.
2 changes: 2 additions & 0 deletions src/ansi-c/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ identifier:
TOK_IDENTIFIER
| TOK_CPROVER_ID TOK_STRING
{
// construct an identifier from a string that would otherwise not be a
// valid identifier in C
$$=$1;
parser_stack($$).id(ID_symbol);
irep_idt value=parser_stack($2).get(ID_value);
Expand Down