Skip to content

Commit 95284f5

Browse files
author
Daniel Kroening
authored
Merge pull request #358 from thk123/bug/typedef-structs-clean
Store the typedef identifier in the symbol_type (cleaned up)
2 parents 8ea36da + eec7a5d commit 95284f5

File tree

126 files changed

+1399
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+1399
-1
lines changed

regression/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ DIRS = ansi-c \
55
cbmc-java \
66
goto-analyzer \
77
goto-instrument \
8+
goto-instrument-typedef \
89
test-script \
910
# Empty last line
1011

regression/ansi-c/gcc_types_compatible_p1/main.c

+11-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ double d;
77
typedef enum T1 { hot, dog, poo, bear } dingos;
88
typedef enum T2 { janette, laura, amanda } cranberry;
99

10+
typedef enum AnonEnum { jim, bob, fred } names;
11+
12+
typedef dingos altdingos;
13+
typedef dingos diffdingos;
14+
15+
typedef names altnames;
16+
typedef names diffnames;
17+
1018
typedef float same1;
1119
typedef float same2;
1220

@@ -52,6 +60,9 @@ STATIC_ASSERT(__builtin_types_compatible_p(typeof (dingos), unsigned)); // ha!
5260
STATIC_ASSERT(__builtin_types_compatible_p(typeof (hot), typeof (laura)));
5361
STATIC_ASSERT(__builtin_types_compatible_p(int[5], int[]));
5462
STATIC_ASSERT(__builtin_types_compatible_p(same1, same2));
63+
STATIC_ASSERT(__builtin_types_compatible_p(dingos, altdingos));
64+
STATIC_ASSERT(__builtin_types_compatible_p(diffdingos, altdingos));
65+
STATIC_ASSERT(__builtin_types_compatible_p(diffnames, altnames));
5566
STATIC_ASSERT(__builtin_types_compatible_p(typeof (hot) *, int *));
5667
STATIC_ASSERT(__builtin_types_compatible_p(typeof (hot), typeof (janette)));
5768
STATIC_ASSERT(__builtin_types_compatible_p(__int128, signed __int128));
@@ -84,7 +95,6 @@ STATIC_ASSERT(!__builtin_types_compatible_p(__float128, long double));
8495
STATIC_ASSERT(!__builtin_types_compatible_p(__float128, double));
8596
STATIC_ASSERT(!__builtin_types_compatible_p(__int128, unsigned __int128));
8697
#endif
87-
8898
#endif
8999

90100
int main(void)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#define STATIC_ASSERT(condition) \
2+
int some_array[(condition) ? 1 : -1];
3+
4+
typedef struct struct_tag
5+
{
6+
int x;
7+
float y;
8+
} struct_typedef;
9+
10+
typedef struct struct_tag alt_typedef;
11+
typedef struct_typedef another_typedef;
12+
13+
#ifdef __GNUC__
14+
15+
16+
STATIC_ASSERT(__builtin_types_compatible_p(struct struct_tag, struct_typedef));
17+
STATIC_ASSERT(__builtin_types_compatible_p(struct struct_tag, alt_typedef));
18+
STATIC_ASSERT(__builtin_types_compatible_p(struct struct_tag, another_typedef));
19+
STATIC_ASSERT(__builtin_types_compatible_p(struct_typedef, alt_typedef));
20+
STATIC_ASSERT(__builtin_types_compatible_p(struct_typedef, another_typedef));
21+
STATIC_ASSERT(__builtin_types_compatible_p(alt_typedef, another_typedef));
22+
23+
#endif
24+
25+
int main(void)
26+
{
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
typedef struct
3+
{
4+
int x;
5+
float y;
6+
} MYSTRUCT;
7+
8+
void fun()
9+
{
10+
MYSTRUCT mystruct_var = {.x = 3, .y = 2.1f};
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
main.c
3+
--show-symbol-table --function fun
4+
// Enable multi-line checking
5+
activate-multi-line-match
6+
EXIT=0
7+
SIGNAL=0
8+
Base name\.+: mystruct_var\nMode\.+: C\nType\.+: MYSTRUCT
9+
--
10+
warning: ignoring
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
typedef struct
3+
{
4+
int x;
5+
float y;
6+
} MYSTRUCT;
7+
8+
void fun()
9+
{
10+
MYSTRUCT mystruct_var = {.x = 10, .y = 3.1f}, another_mystruct_var = {.x = 3, .y = 2.1f};
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
main.c
3+
--show-symbol-table --function fun
4+
// Enable multi-line checking
5+
activate-multi-line-match
6+
EXIT=0
7+
SIGNAL=0
8+
Base name\.+: mystruct_var\nMode\.+: C\nType\.+: MYSTRUCT
9+
Base name\.+: another_mystruct_var\nMode\.+: C\nType\.+: MYSTRUCT
10+
--
11+
warning: ignoring
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
typedef union
3+
{
4+
int x;
5+
float y;
6+
} MYUNION;
7+
8+
void fun()
9+
{
10+
MYUNION myunion_var = {.y = 2.1f};
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
main.c
3+
--show-symbol-table --function fun
4+
// Enable multi-line checking
5+
activate-multi-line-match
6+
EXIT=0
7+
SIGNAL=0
8+
Base name\.+: myunion_var\nMode\.+: C\nType\.+: MYUNION
9+
--
10+
warning: ignoring
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
typedef union
3+
{
4+
int x;
5+
float y;
6+
} MYUNION;
7+
8+
void fun()
9+
{
10+
MYUNION myunion_var = {.y = 2.1f}, another_myunion_var = {.y = 2.1f};
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
main.c
3+
--show-symbol-table --function fun
4+
// Enable multi-line checking
5+
activate-multi-line-match
6+
EXIT=0
7+
SIGNAL=0
8+
Base name\.+: myunion_var\nMode\.+: C\nType\.+: MYUNION
9+
Base name\.+: another_myunion_var\nMode\.+: C\nType\.+: MYUNION
10+
--
11+
warning: ignoring
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
typedef struct tag_struct_name
3+
{
4+
int x;
5+
float y;
6+
} MYSTRUCT;
7+
8+
void fun()
9+
{
10+
const struct tag_struct_name tag_struct_var = {.x = 1, .y = 3.14f};
11+
const MYSTRUCT mystruct_var = {.x = 3, .y = 2.1f};
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
main.c
3+
--show-symbol-table --function fun
4+
// Enable multi-line checking
5+
activate-multi-line-match
6+
EXIT=0
7+
SIGNAL=0
8+
Base name\.+: tag_struct_var\nMode\.+: C\nType\.+: const struct tag_struct_name
9+
Base name\.+: mystruct_var\nMode\.+: C\nType\.+: const MYSTRUCT
10+
--
11+
warning: ignoring
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
typedef int MYINT;
3+
4+
void fun()
5+
{
6+
const int int_var = 3;
7+
const MYINT myint_var = 5;
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
main.c
3+
--show-symbol-table --function fun
4+
// Enable multi-line checking
5+
activate-multi-line-match
6+
EXIT=0
7+
SIGNAL=0
8+
Base name\.+: int_var\nMode\.+: C\nType\.+: const signed int
9+
Base name\.+: myint_var\nMode\.+: C\nType\.+: const MYINT
10+
--
11+
warning: ignoring
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
typedef union tag_union_name
3+
{
4+
int x;
5+
float y;
6+
} MYUNION;
7+
8+
void fun()
9+
{
10+
const union tag_union_name tag_union_var = {1};
11+
const MYUNION myunion_var = {.y = 2.1f};
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
main.c
3+
--show-symbol-table --function fun
4+
// Enable multi-line checking
5+
activate-multi-line-match
6+
EXIT=0
7+
SIGNAL=0
8+
Base name\.+: tag_union_var\nMode\.+: C\nType\.+: const union tag_union_name
9+
Base name\.+: myunion_var\nMode\.+: C\nType\.+: const MYUNION
10+
--
11+
warning: ignoring
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
typedef struct
3+
{
4+
int x;
5+
float y;
6+
} MYSTRUCT;
7+
8+
void fun(MYSTRUCT mystruct_param)
9+
{
10+
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
main.c
3+
--show-symbol-table --function fun
4+
// Enable multi-line checking
5+
activate-multi-line-match
6+
EXIT=0
7+
SIGNAL=0
8+
Base name\.+: mystruct_param\nMode\.+: C\nType\.+: MYSTRUCT
9+
--
10+
warning: ignoring
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
typedef union
3+
{
4+
int x;
5+
float y;
6+
} MYUNION;
7+
8+
void fun(MYUNION myunion_param)
9+
{
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
main.c
3+
--show-symbol-table --function fun
4+
// Enable multi-line checking
5+
activate-multi-line-match
6+
EXIT=0
7+
SIGNAL=0
8+
Base name\.+: myunion_param\nMode\.+: C\nType\.+: MYUNION
9+
--
10+
warning: ignoring
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
typedef struct tag_struct_name
3+
{
4+
int x;
5+
float y;
6+
} MYSTRUCT;
7+
8+
void fun(struct tag_struct_name tag_struct_param, MYSTRUCT mystruct_param)
9+
{
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
main.c
3+
--show-symbol-table --function fun
4+
// Enable multi-line checking
5+
activate-multi-line-match
6+
EXIT=0
7+
SIGNAL=0
8+
Base name\.+: tag_struct_param\nMode\.+: C\nType\.+: struct tag_struct_name
9+
Base name\.+: mystruct_param\nMode\.+: C\nType\.+: MYSTRUCT
10+
--
11+
warning: ignoring
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
typedef int MYINT;
3+
4+
void fun(int int_param, MYINT myint_param)
5+
{
6+
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
main.c
3+
--show-symbol-table --function fun
4+
// Enable multi-line checking
5+
activate-multi-line-match
6+
EXIT=0
7+
SIGNAL=0
8+
Base name\.+: int_param\nMode\.+: C\nType\.+: signed int
9+
Base name\.+: myint_param\nMode\.+: C\nType\.+: MYINT
10+
--
11+
warning: ignoring
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
typedef int MYINT;
3+
typedef int ALTINT;
4+
5+
void fun(int int_param, MYINT myint_param, ALTINT altint_param)
6+
{
7+
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
main.c
3+
--show-symbol-table --function fun
4+
// Enable multi-line checking
5+
activate-multi-line-match
6+
EXIT=0
7+
SIGNAL=0
8+
Base name\.+: int_param\nMode\.+: C\nType\.+: signed int
9+
Base name\.+: myint_param\nMode\.+: C\nType\.+: MYINT
10+
Base name\.+: altint_param\nMode\.+: C\nType\.+: ALTINT
11+
--
12+
warning: ignoring
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
typedef int MYINT;
3+
typedef MYINT CHAINEDINT;
4+
5+
void fun(int int_param, MYINT myint_param, CHAINEDINT chainedint_param)
6+
{
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
main.c
3+
--show-symbol-table --function fun
4+
// Enable multi-line checking
5+
activate-multi-line-match
6+
EXIT=0
7+
SIGNAL=0
8+
Base name\.+: int_param\nMode\.+: C\nType\.+: signed int
9+
Base name\.+: myint_param\nMode\.+: C\nType\.+: MYINT
10+
Base name\.+: chainedint_param\nMode\.+: C\nType\.+: CHAINEDINT
11+
--
12+
warning: ignoring
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
typedef union tag_union_name
3+
{
4+
int x;
5+
float y;
6+
} MYUNION;
7+
8+
void fun(union tag_union_name tag_union_param, MYUNION myunion_param)
9+
{
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
main.c
3+
--show-symbol-table --function fun
4+
// Enable multi-line checking
5+
activate-multi-line-match
6+
EXIT=0
7+
SIGNAL=0
8+
Base name\.+: tag_union_param\nMode\.+: C\nType\.+: union tag_union_name
9+
Base name\.+: myunion_param\nMode\.+: C\nType\.+: MYUNION
10+
--
11+
warning: ignoring

0 commit comments

Comments
 (0)