File tree Expand file tree Collapse file tree 4 files changed +26
-2
lines changed
regression/ansi-c/invalid_function_definition1 Expand file tree Collapse file tree 4 files changed +26
-2
lines changed Original file line number Diff line number Diff line change
1
+ void a () = {};
Original file line number Diff line number Diff line change
1
+ CORE test-c++-front-end
2
+ main.c
3
+
4
+ ^EXIT=(64|1)$
5
+ ^SIGNAL=0$
6
+ function 'a(\(\))?' is initialized with initializer_list
7
+ ^CONVERSION ERROR$
8
+ --
9
+ Invariant check failed
Original file line number Diff line number Diff line change @@ -505,9 +505,15 @@ void c_typecheck_baset::typecheck_redefinition_non_type(
505
505
506
506
void c_typecheck_baset::typecheck_function_body (symbolt &symbol)
507
507
{
508
- code_typet &code_type=to_code_type (symbol.type );
508
+ if (symbol.value .id () != ID_code)
509
+ {
510
+ error ().source_location = symbol.location ;
511
+ error () << " function '" << symbol.name << " ' is initialized with "
512
+ << symbol.value .id () << eom;
513
+ throw 0 ;
514
+ }
509
515
510
- assert (symbol.value . is_not_nil () );
516
+ code_typet &code_type = to_code_type (symbol.type );
511
517
512
518
// reset labels
513
519
labels_used.clear ();
Original file line number Diff line number Diff line change @@ -91,6 +91,14 @@ void cpp_typecheckt::convert_function(symbolt &symbol)
91
91
if (symbol.value .is_nil ())
92
92
return ;
93
93
94
+ if (symbol.value .id () != ID_code)
95
+ {
96
+ error ().source_location = symbol.location ;
97
+ error () << " function '" << symbol.name << " ' is initialized with "
98
+ << symbol.value .id () << eom;
99
+ throw 0 ;
100
+ }
101
+
94
102
// enter appropriate scope
95
103
cpp_save_scopet saved_scope (cpp_scopes);
96
104
cpp_scopet &function_scope=cpp_scopes.set_scope (symbol.name );
You can’t perform that action at this time.
0 commit comments