diff options
author | Tom de Vries <tdevries@suse.de> | 2022-02-07 14:50:13 +0100 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2022-02-08 09:55:31 +0100 |
commit | 73f4a989b7f8aeaf8bff37e7f33b65d26b8f179f (patch) | |
tree | 7b5a804e154677b6ffcfa61f3414a72ff3cd08cc /gcc/config/nvptx/nvptx.cc | |
parent | f05cc4fd6f0f52b8629ed6f7c068b5b2de7fa627 (diff) | |
download | gcc-73f4a989b7f8aeaf8bff37e7f33b65d26b8f179f.zip gcc-73f4a989b7f8aeaf8bff37e7f33b65d26b8f179f.tar.gz gcc-73f4a989b7f8aeaf8bff37e7f33b65d26b8f179f.tar.bz2 |
[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)'.
Diffstat (limited to 'gcc/config/nvptx/nvptx.cc')
-rw-r--r-- | gcc/config/nvptx/nvptx.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc index 2a69492..006fac8 100644 --- a/gcc/config/nvptx/nvptx.cc +++ b/gcc/config/nvptx/nvptx.cc @@ -938,10 +938,13 @@ write_fn_proto_1 (std::stringstream &s, bool is_defn, if (DECL_STATIC_CHAIN (decl)) argno = write_arg_type (s, -1, argno, ptr_type_node, true); - if (!argno && strcmp (name, "main") == 0) + if (argno < 2 && strcmp (name, "main") == 0) { - argno = write_arg_type (s, -1, argno, integer_type_node, true); - argno = write_arg_type (s, -1, argno, ptr_type_node, true); + if (argno == 0) + argno = write_arg_type (s, -1, argno, integer_type_node, true); + + if (argno == 1) + argno = write_arg_type (s, -1, argno, ptr_type_node, true); } if (argno) |