Skip to content

C front-end: tolerate type differences with asm renaming #7584

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
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
26 changes: 26 additions & 0 deletions regression/ansi-c/asm4/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// from Fedora's glibc
struct dirent
{
int dummy;
};

struct dirent64
{
int dummy;
};

#ifdef __GNUC__
extern struct dirent *readdir(void *__dirp) __asm__(
""
"readdir64");
extern struct dirent64 *readdir64(void *__dirp);
#endif

int main()
{
#ifdef __GNUC__
int x;
(void)readdir(&x);
#endif
return 0;
}
8 changes: 8 additions & 0 deletions regression/ansi-c/asm4/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE test-c++-front-end
main.c

^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
^CONVERSION ERROR$
5 changes: 3 additions & 2 deletions regression/cbmc-library/sscanf-01/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

int main()
{
sscanf();
assert(0);
char dest[10];
int result = sscanf("hello", "%s", dest);
assert(result == 1);
return 0;
}
10 changes: 6 additions & 4 deletions regression/cbmc-library/sscanf-01/test.desc
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
KNOWNBUG
CORE
main.c
--pointer-check --bounds-check
^EXIT=0$

^\[main.assertion.1\] line 8 assertion result == 1: FAILURE$
^\*\* 1 of \d+ failed
^VERIFICATION FAILED$
^EXIT=10$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
15 changes: 13 additions & 2 deletions regression/cbmc-library/vfscanf-01/main.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>

int xscanf(const char *format, ...)
{
va_list list;
va_start(list, format);
int result = vfscanf(stdin, format, list);
va_end(list);
return result;
}

int main()
{
vfscanf();
assert(0);
char dest[10];
int result = xscanf("%s", dest);
assert(result == 1);
return 0;
}
10 changes: 6 additions & 4 deletions regression/cbmc-library/vfscanf-01/test.desc
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
KNOWNBUG
CORE
main.c
--pointer-check --bounds-check
^EXIT=0$

^\[main.assertion.1\] line 18 assertion result == 1: FAILURE$
^\*\* 1 of \d+ failed
^VERIFICATION FAILED$
^EXIT=10$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
15 changes: 13 additions & 2 deletions regression/cbmc-library/vscanf-01/main.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>

int xscanf(const char *format, ...)
{
va_list list;
va_start(list, format);
int result = vscanf(format, list);
va_end(list);
return result;
}

int main()
{
vscanf();
assert(0);
char dest[10];
int result = xscanf("%s", dest);
assert(result == 1);
return 0;
}
10 changes: 6 additions & 4 deletions regression/cbmc-library/vscanf-01/test.desc
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
KNOWNBUG
CORE
main.c
--pointer-check --bounds-check
^EXIT=0$

^\[main.assertion.1\] line 18 assertion result == 1: FAILURE$
^\*\* 1 of \d+ failed
^VERIFICATION FAILED$
^EXIT=10$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
15 changes: 13 additions & 2 deletions regression/cbmc-library/vsscanf-01/main.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>

int xscanf(const char *format, ...)
{
va_list list;
va_start(list, format);
int result = vsscanf("hello", format, list);
va_end(list);
return result;
}

int main()
{
vsscanf();
assert(0);
char dest[10];
int result = xscanf("%s", dest);
assert(result == 1);
return 0;
}
10 changes: 6 additions & 4 deletions regression/cbmc-library/vsscanf-01/test.desc
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
KNOWNBUG
CORE
main.c
--pointer-check --bounds-check
^EXIT=0$

^\[main.assertion.1\] line 18 assertion result == 1: FAILURE$
^\*\* 1 of \d+ failed
^VERIFICATION FAILED$
^EXIT=10$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
4 changes: 4 additions & 0 deletions src/ansi-c/c_typecheck_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,10 @@ void c_typecheck_baset::apply_asm_label(
{
symbol.name=asm_label;
symbol.base_name=asm_label;
// asm renaming may be combined with varied return types - make sure the
// actual definition sets the final type
if(symbol.type.id() == ID_code)
symbol.type.set(ID_C_incomplete, true);
}

if(symbol.name!=orig_name)
Expand Down
Loading