diff options
| author | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2020-11-25 00:00:00 +0000 |
|---|---|---|
| committer | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2020-11-25 00:00:00 +0000 |
| commit | 22d3431221df2e9136d303d1762ea7afdded1b5e (patch) | |
| tree | 7968a31ba31fa97d8e9c569a39268f7654f1e560 /src/test/codegen | |
| parent | 773ddbada7183b57928a1d2f5e0722b7f53a3bf7 (diff) | |
| download | rust-22d3431221df2e9136d303d1762ea7afdded1b5e.tar.gz rust-22d3431221df2e9136d303d1762ea7afdded1b5e.zip | |
Validate use of parameters in naked functions
* Reject use of parameters inside naked function body. * Reject use of patterns inside function parameters, to emphasize role of parameters a signature declaration (mirroring existing behaviour for function declarations) and avoid generating code introducing specified bindings.
Diffstat (limited to 'src/test/codegen')
| -rw-r--r-- | src/test/codegen/naked-functions.rs | 54 |
1 files changed, 5 insertions, 49 deletions
diff --git a/src/test/codegen/naked-functions.rs b/src/test/codegen/naked-functions.rs index 5e76f1d67e6..43a6be465bc 100644 --- a/src/test/codegen/naked-functions.rs +++ b/src/test/codegen/naked-functions.rs @@ -1,4 +1,4 @@ -// compile-flags: -C no-prepopulate-passes -Zmir-opt-level=0 +// compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] #![feature(naked_functions)] @@ -15,11 +15,9 @@ pub fn naked_empty() { // CHECK: Function Attrs: naked #[no_mangle] #[naked] -// CHECK-NEXT: define void @naked_with_args(i{{[0-9]+( %0)?}}) +// CHECK-NEXT: define void @naked_with_args(i{{[0-9]+( %a)?}}) pub fn naked_with_args(a: isize) { // CHECK-NEXT: {{.+}}: - // CHECK-NEXT: %a = alloca i{{[0-9]+}} - &a; // keep variable in an alloca // CHECK: ret void } @@ -34,53 +32,11 @@ pub fn naked_with_return() -> isize { } // CHECK: Function Attrs: naked -// CHECK-NEXT: define i{{[0-9]+}} @naked_with_args_and_return(i{{[0-9]+( %0)?}}) +// CHECK-NEXT: define i{{[0-9]+}} @naked_with_args_and_return(i{{[0-9]+( %a)?}}) #[no_mangle] #[naked] pub fn naked_with_args_and_return(a: isize) -> isize { // CHECK-NEXT: {{.+}}: - // CHECK-NEXT: %a = alloca i{{[0-9]+}} - &a; // keep variable in an alloca - // CHECK: ret i{{[0-9]+}} %{{[0-9]+}} - a -} - -// CHECK: Function Attrs: naked -// CHECK-NEXT: define void @naked_recursive() -#[no_mangle] -#[naked] -pub fn naked_recursive() { - // CHECK-NEXT: {{.+}}: - // CHECK-NEXT: call void @naked_empty() - - // FIXME(#39685) Avoid one block per call. - // CHECK-NEXT: br label %bb1 - // CHECK: bb1: - - naked_empty(); - - // CHECK-NEXT: %_4 = call i{{[0-9]+}} @naked_with_return() - - // FIXME(#39685) Avoid one block per call. - // CHECK-NEXT: br label %bb2 - // CHECK: bb2: - - // CHECK-NEXT: %_3 = call i{{[0-9]+}} @naked_with_args_and_return(i{{[0-9]+}} %_4) - - // FIXME(#39685) Avoid one block per call. - // CHECK-NEXT: br label %bb3 - // CHECK: bb3: - - // CHECK-NEXT: call void @naked_with_args(i{{[0-9]+}} %_3) - - // FIXME(#39685) Avoid one block per call. - // CHECK-NEXT: br label %bb4 - // CHECK: bb4: - - naked_with_args( - naked_with_args_and_return( - naked_with_return() - ) - ); - // CHECK-NEXT: ret void + // CHECK: ret i{{[0-9]+}} 0 + 0 } |
