[nvptx] Fix 'main (int argc)' compilation
authorTom de Vries <tdevries@suse.de>
Mon, 7 Feb 2022 13:50:13 +0000 (14:50 +0100)
committerTom de Vries <tdevries@suse.de>
Tue, 8 Feb 2022 08:55:31 +0000 (09:55 +0100)
commit73f4a989b7f8aeaf8bff37e7f33b65d26b8f179f
tree7b5a804e154677b6ffcfa61f3414a72ff3cd08cc
parentf05cc4fd6f0f52b8629ed6f7c068b5b2de7fa627
[nvptx] Fix 'main (int argc)' compilation

On nvptx, with test-case sso-12.c I run into:
...
spawn nvptx-none-run ./sso-12.exe^M
error: Prototype doesn't match for 'main' in 'input file 1 at offset 1796', \
  first defined in 'input file 1 at offset 1796'^M
nvptx-run: cuLinkAddData failed: device kernel image is invalid \
  (CUDA_ERROR_INVALID_SOURCE, 300)^M
FAIL: gcc.dg/sso-12.c execution test
...

The problem is that the test case uses 'main (int)' prototype, while __main
uses:
...
extern int main (int, void **);
...

There's code in write_fn_proto_1 to handle 'main (void)' as if
'main (int, void **)' was specified, but that's not active for 'main (int)'.

Fix this in write_fn_proto_1 by handling 'main (int)' as if
'main (int, void **)' was specified.

Tested on nvptx.

gcc/ChangeLog:

2022-02-07  Tom de Vries  <tdevries@suse.de>

* config/nvptx/nvptx.cc (write_fn_proto_1): Handle 'main (int)'.
gcc/config/nvptx/nvptx.cc