File tree Expand file tree Collapse file tree 2 files changed +23
-7
lines changed
regression/cbmc/constructor1 Expand file tree Collapse file tree 2 files changed +23
-7
lines changed Original file line number Diff line number Diff line change 1
1
#include <assert.h>
2
2
3
3
#ifdef __GNUC__
4
- int x , y ;
4
+ int x , y , z ;
5
5
6
6
// forward declaration with and without attribute is ok
7
7
static __attribute__((constructor )) void format_init (void );
8
8
static void other_init (void );
9
+ static __attribute__((constructor )) void more_init (void );
9
10
10
11
static __attribute__((constructor ))
11
12
void format_init (void )
@@ -18,13 +19,19 @@ static __attribute__((constructor)) void other_init(void)
18
19
{
19
20
y = 42 ;
20
21
}
22
+
23
+ static void more_init (void )
24
+ {
25
+ z = 42 ;
26
+ }
21
27
#endif
22
28
23
29
int main ()
24
30
{
25
31
#ifdef __GNUC__
26
32
assert (x == 42 );
27
33
assert (y == 42 );
34
+ assert (z == 42 );
28
35
#endif
29
36
return 0 ;
30
37
}
Original file line number Diff line number Diff line change @@ -379,12 +379,21 @@ void c_typecheck_baset::typecheck_redefinition_non_type(
379
379
new_ct.return_type ().id () != ID_constructor &&
380
380
new_ct.return_type ().id () != ID_destructor)
381
381
{
382
- throw invalid_source_file_exceptiont{
383
- " function symbol '" + id2string (new_symbol.display_name ()) +
384
- " ' redefined with a different type:\n " +
385
- " Original: " + to_string (old_symbol.type ) + " \n " +
386
- " New: " + to_string (new_symbol.type ),
387
- new_symbol.location };
382
+ if (
383
+ old_ct.return_type ().id () == ID_constructor ||
384
+ old_ct.return_type ().id () == ID_destructor)
385
+ {
386
+ new_ct = old_ct;
387
+ }
388
+ else
389
+ {
390
+ throw invalid_source_file_exceptiont{
391
+ " function symbol '" + id2string (new_symbol.display_name ()) +
392
+ " ' redefined with a different type:\n " +
393
+ " Original: " + to_string (old_symbol.type ) + " \n " +
394
+ " New: " + to_string (new_symbol.type ),
395
+ new_symbol.location };
396
+ }
388
397
}
389
398
const bool inlined = old_ct.get_inlined () || new_ct.get_inlined ();
390
399
You can’t perform that action at this time.
0 commit comments