]> git.proxmox.com Git - rustc.git/blame - tests/ui/parser/variadic-ffi-semantic-restrictions.rs
New upstream version 1.75.0+dfsg1
[rustc.git] / tests / ui / parser / variadic-ffi-semantic-restrictions.rs
CommitLineData
dfeec247 1#![feature(c_variadic)]
cdc7bbd5 2#![allow(anonymous_parameters)]
dfeec247
XL
3
4fn main() {}
5
6fn f1_1(x: isize, ...) {}
136023e0 7//~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
dfeec247
XL
8
9fn f1_2(...) {}
136023e0 10//~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
dfeec247
XL
11//~| ERROR C-variadic function must be declared with at least one named argument
12
13extern "C" fn f2_1(x: isize, ...) {}
136023e0 14//~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
dfeec247
XL
15
16extern "C" fn f2_2(...) {}
136023e0 17//~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
dfeec247
XL
18//~| ERROR C-variadic function must be declared with at least one named argument
19
20extern "C" fn f2_3(..., x: isize) {}
136023e0 21//~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
dfeec247
XL
22//~| ERROR `...` must be the last argument of a C-variadic function
23
5869c6ff 24extern "C" fn f3_1(x: isize, ...) {}
136023e0 25//~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
dfeec247 26
5869c6ff 27extern "C" fn f3_2(...) {}
136023e0 28//~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
dfeec247
XL
29//~| ERROR C-variadic function must be declared with at least one named argument
30
5869c6ff 31extern "C" fn f3_3(..., x: isize) {}
136023e0 32//~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
dfeec247
XL
33//~| ERROR `...` must be the last argument of a C-variadic function
34
ed00b5ec
FG
35const unsafe extern "C" fn f4_1(x: isize, ...) {}
36//~^ ERROR functions cannot be both `const` and C-variadic
37
38const extern "C" fn f4_2(x: isize, ...) {}
39//~^ ERROR functions cannot be both `const` and C-variadic
40//~| ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
41
42const extern "C" fn f4_3(..., x: isize, ...) {}
43//~^ ERROR functions cannot be both `const` and C-variadic
44//~| ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
45//~| ERROR `...` must be the last argument of a C-variadic function
46
5869c6ff 47extern "C" {
dfeec247
XL
48 fn e_f1(...);
49 //~^ ERROR C-variadic function must be declared with at least one named argument
50 fn e_f2(..., x: isize);
5869c6ff 51//~^ ERROR `...` must be the last argument of a C-variadic function
dfeec247
XL
52}
53
54struct X;
55
56impl X {
57 fn i_f1(x: isize, ...) {}
136023e0 58 //~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
dfeec247 59 fn i_f2(...) {}
136023e0 60 //~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
dfeec247
XL
61 //~| ERROR C-variadic function must be declared with at least one named argument
62 fn i_f3(..., x: isize, ...) {}
136023e0 63 //~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
dfeec247
XL
64 //~| ERROR `...` must be the last argument of a C-variadic function
65 fn i_f4(..., x: isize, ...) {}
136023e0 66 //~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
dfeec247 67 //~| ERROR `...` must be the last argument of a C-variadic function
ed00b5ec
FG
68 const fn i_f5(x: isize, ...) {}
69 //~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
70 //~| ERROR functions cannot be both `const` and C-variadic
dfeec247
XL
71}
72
73trait T {
74 fn t_f1(x: isize, ...) {}
136023e0 75 //~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
dfeec247 76 fn t_f2(x: isize, ...);
136023e0 77 //~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
dfeec247 78 fn t_f3(...) {}
136023e0 79 //~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
dfeec247
XL
80 //~| ERROR C-variadic function must be declared with at least one named argument
81 fn t_f4(...);
136023e0 82 //~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
dfeec247
XL
83 //~| ERROR C-variadic function must be declared with at least one named argument
84 fn t_f5(..., x: isize) {}
136023e0 85 //~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
dfeec247
XL
86 //~| ERROR `...` must be the last argument of a C-variadic function
87 fn t_f6(..., x: isize);
136023e0 88 //~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
dfeec247
XL
89 //~| ERROR `...` must be the last argument of a C-variadic function
90}