File tree Expand file tree Collapse file tree 3 files changed +25
-1
lines changed Expand file tree Collapse file tree 3 files changed +25
-1
lines changed Original file line number Diff line number Diff line change
1
+ int main (char * argv , int arc )
2
+ {
3
+ return 0 ;
4
+ }
Original file line number Diff line number Diff line change
1
+ CORE test-c++-front-end
2
+ main.c
3
+
4
+ 'main' with signature 'signed int \(char \*argv, signed int arc\)' found
5
+ ^EXIT=(64|1)$
6
+ ^SIGNAL=0$
7
+ --
8
+ Invariant check failed
9
+ --
10
+ This test is to ensure that non-standard C entry points are handled gracefully
11
+ and with a message to the user.
Original file line number Diff line number Diff line change @@ -248,7 +248,16 @@ bool generate_ansi_c_start_function(
248
248
{
249
249
// ok
250
250
}
251
- else if (parameters.size ()==2 || parameters.size ()==3 )
251
+ // The C standard (and any related architecture descriptions) enforces an
252
+ // order of parameters. The user, however, may supply arbitrary
253
+ // (syntactically valid) C code, even one that does not respect the calling
254
+ // conventions set out in the C standard. If the user does supply such code,
255
+ // then we can only tell them that they got it wrong, which is what we do
256
+ // via the error message in the else branch of this code.
257
+ else if (
258
+ parameters.size () >= 2 && parameters[1 ].type ().id () == ID_pointer &&
259
+ (parameters.size () == 2 ||
260
+ (parameters.size () == 3 && parameters[2 ].type ().id () == ID_pointer)))
252
261
{
253
262
namespacet ns (symbol_table);
254
263
You can’t perform that action at this time.
0 commit comments