Skip to content

Commit 00c5499

Browse files
committed
Update tests
1 parent 18a5c4a commit 00c5499

56 files changed

Lines changed: 785 additions & 2016 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎tests/multi-file/cross_tu_anon_enum_collision/out/refcount/cross_tu_anon_enum_collision.rs‎

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,11 @@ use std::io::prelude::*;
66
use std::io::{Read, Seek, Write};
77
use std::os::fd::AsFd;
88
use std::rc::{Rc, Weak};
9-
#[derive(Clone, Copy, PartialEq, Debug, Default)]
10-
enum anon_0 {
11-
#[default]
12-
ALPHA = 7,
13-
}
14-
impl From<i32> for anon_0 {
15-
fn from(n: i32) -> anon_0 {
16-
match n {
17-
7 => anon_0::ALPHA,
18-
_ => panic!("invalid anon_0 value: {}", n),
19-
}
20-
}
21-
}
22-
libcc2rs::impl_enum_inc_dec!(anon_0);
23-
impl ByteRepr for anon_0 {
24-
fn to_bytes(&self, buf: &mut [u8]) {
25-
(*self as i32).to_bytes(buf);
26-
}
27-
fn from_bytes(buf: &[u8]) -> Self {
28-
<anon_0>::from(i32::from_bytes(buf))
29-
}
30-
}
9+
pub type anon_0 = u32;
10+
pub const anon_0_ALPHA: anon_0 = 7;
3111
pub fn a_value_1() -> i32 {
3212
let x: Value<i32> = Rc::new(RefCell::new(0));
33-
(*x.borrow_mut()) |= (anon_0::ALPHA as i32);
13+
(*x.borrow_mut()) |= (anon_0_ALPHA as i32);
3414
return (*x.borrow());
3515
}
3616
pub fn main() {
@@ -41,30 +21,10 @@ fn main_0() -> i32 {
4121
assert!((((({ b_value_2() }) == 9) as i32) != 0));
4222
return 0;
4323
}
44-
#[derive(Clone, Copy, PartialEq, Debug, Default)]
45-
enum anon_3 {
46-
#[default]
47-
BETA = 9,
48-
}
49-
impl From<i32> for anon_3 {
50-
fn from(n: i32) -> anon_3 {
51-
match n {
52-
9 => anon_3::BETA,
53-
_ => panic!("invalid anon_3 value: {}", n),
54-
}
55-
}
56-
}
57-
libcc2rs::impl_enum_inc_dec!(anon_3);
58-
impl ByteRepr for anon_3 {
59-
fn to_bytes(&self, buf: &mut [u8]) {
60-
(*self as i32).to_bytes(buf);
61-
}
62-
fn from_bytes(buf: &[u8]) -> Self {
63-
<anon_3>::from(i32::from_bytes(buf))
64-
}
65-
}
24+
pub type anon_3 = u32;
25+
pub const anon_3_BETA: anon_3 = 9;
6626
pub fn b_value_2() -> i32 {
6727
let x: Value<i32> = Rc::new(RefCell::new(0));
68-
(*x.borrow_mut()) |= (anon_3::BETA as i32);
28+
(*x.borrow_mut()) |= (anon_3_BETA as i32);
6929
return (*x.borrow());
7030
}

‎tests/multi-file/cross_tu_anon_enum_collision/out/unsafe/cross_tu_anon_enum_collision.rs‎

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,11 @@ use std::collections::BTreeMap;
66
use std::io::{Read, Seek, Write};
77
use std::os::fd::{AsFd, FromRawFd, IntoRawFd};
88
use std::rc::Rc;
9-
#[derive(Clone, Copy, PartialEq, Debug, Default)]
10-
enum anon_0 {
11-
#[default]
12-
ALPHA = 7,
13-
}
14-
impl From<i32> for anon_0 {
15-
fn from(n: i32) -> anon_0 {
16-
match n {
17-
7 => anon_0::ALPHA,
18-
_ => panic!("invalid anon_0 value: {}", n),
19-
}
20-
}
21-
}
22-
libcc2rs::impl_enum_inc_dec!(anon_0);
9+
pub type anon_0 = u32;
10+
pub const anon_0_ALPHA: anon_0 = 7;
2311
pub unsafe fn a_value_1() -> i32 {
2412
let mut x: i32 = 0;
25-
x |= (anon_0::ALPHA as i32);
13+
x |= (anon_0_ALPHA as i32);
2614
return x;
2715
}
2816
pub fn main() {
@@ -35,22 +23,10 @@ unsafe fn main_0() -> i32 {
3523
assert!(((((unsafe { b_value_2() }) == (9)) as i32) != 0));
3624
return 0;
3725
}
38-
#[derive(Clone, Copy, PartialEq, Debug, Default)]
39-
enum anon_3 {
40-
#[default]
41-
BETA = 9,
42-
}
43-
impl From<i32> for anon_3 {
44-
fn from(n: i32) -> anon_3 {
45-
match n {
46-
9 => anon_3::BETA,
47-
_ => panic!("invalid anon_3 value: {}", n),
48-
}
49-
}
50-
}
51-
libcc2rs::impl_enum_inc_dec!(anon_3);
26+
pub type anon_3 = u32;
27+
pub const anon_3_BETA: anon_3 = 9;
5228
pub unsafe fn b_value_2() -> i32 {
5329
let mut x: i32 = 0;
54-
x |= (anon_3::BETA as i32);
30+
x |= (anon_3_BETA as i32);
5531
return x;
5632
}

‎tests/multi-file/cross_tu_tag_collision/out/refcount/cross_tu_tag_collision.rs‎

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -43,33 +43,11 @@ fn main_0() -> i32 {
4343
assert!((((({ b_value_1() }) == 2) as i32) != 0));
4444
return 0;
4545
}
46-
#[derive(Clone, Copy, PartialEq, Debug, Default)]
47-
enum widget_enum {
48-
#[default]
49-
WIDGET_A = 0,
50-
WIDGET_B = 1,
51-
WIDGET_C = 2,
52-
}
53-
impl From<i32> for widget_enum {
54-
fn from(n: i32) -> widget_enum {
55-
match n {
56-
0 => widget_enum::WIDGET_A,
57-
1 => widget_enum::WIDGET_B,
58-
2 => widget_enum::WIDGET_C,
59-
_ => panic!("invalid widget_enum value: {}", n),
60-
}
61-
}
62-
}
63-
libcc2rs::impl_enum_inc_dec!(widget_enum);
64-
impl ByteRepr for widget_enum {
65-
fn to_bytes(&self, buf: &mut [u8]) {
66-
(*self as i32).to_bytes(buf);
67-
}
68-
fn from_bytes(buf: &[u8]) -> Self {
69-
<widget_enum>::from(i32::from_bytes(buf))
70-
}
71-
}
46+
pub type widget_enum = u32;
47+
pub const widget_enum_WIDGET_A: widget_enum = 0;
48+
pub const widget_enum_WIDGET_B: widget_enum = 1;
49+
pub const widget_enum_WIDGET_C: widget_enum = 2;
7250
pub fn b_value_1() -> i32 {
73-
let w: Value<widget_enum> = Rc::new(RefCell::new(widget_enum::WIDGET_C));
51+
let w: Value<widget_enum> = Rc::new(RefCell::new(widget_enum_WIDGET_C));
7452
return ((*w.borrow()) as i32);
7553
}

‎tests/multi-file/cross_tu_tag_collision/out/unsafe/cross_tu_tag_collision.rs‎

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,11 @@ unsafe fn main_0() -> i32 {
2626
assert!(((((unsafe { b_value_1() }) == (2)) as i32) != 0));
2727
return 0;
2828
}
29-
#[derive(Clone, Copy, PartialEq, Debug, Default)]
30-
enum widget_enum {
31-
#[default]
32-
WIDGET_A = 0,
33-
WIDGET_B = 1,
34-
WIDGET_C = 2,
35-
}
36-
impl From<i32> for widget_enum {
37-
fn from(n: i32) -> widget_enum {
38-
match n {
39-
0 => widget_enum::WIDGET_A,
40-
1 => widget_enum::WIDGET_B,
41-
2 => widget_enum::WIDGET_C,
42-
_ => panic!("invalid widget_enum value: {}", n),
43-
}
44-
}
45-
}
46-
libcc2rs::impl_enum_inc_dec!(widget_enum);
29+
pub type widget_enum = u32;
30+
pub const widget_enum_WIDGET_A: widget_enum = 0;
31+
pub const widget_enum_WIDGET_B: widget_enum = 1;
32+
pub const widget_enum_WIDGET_C: widget_enum = 2;
4733
pub unsafe fn b_value_1() -> i32 {
48-
let mut w: widget_enum = widget_enum::WIDGET_C;
34+
let mut w: widget_enum = widget_enum_WIDGET_C;
4935
return (w as i32);
5036
}

‎tests/ub/enum_out_of_range_cast.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// panic-ub
1+
// nondet-result
22

33
enum Color { RED, GREEN, BLUE };
44

‎tests/ub/enum_out_of_range_increment.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// panic-ub
1+
// nondet-result
22

33
enum color { RED, GREEN, BLUE };
44

‎tests/ub/out/refcount/enum_out_of_range_cast.rs‎

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,17 @@ use std::io::prelude::*;
66
use std::io::{Read, Seek, Write};
77
use std::os::fd::AsFd;
88
use std::rc::{Rc, Weak};
9-
#[derive(Clone, Copy, PartialEq, Debug, Default)]
10-
enum Color {
11-
#[default]
12-
RED = 0,
13-
GREEN = 1,
14-
BLUE = 2,
15-
}
16-
impl From<i32> for Color {
17-
fn from(n: i32) -> Color {
18-
match n {
19-
0 => Color::RED,
20-
1 => Color::GREEN,
21-
2 => Color::BLUE,
22-
_ => panic!("invalid Color value: {}", n),
23-
}
24-
}
25-
}
26-
libcc2rs::impl_enum_inc_dec!(Color);
27-
impl ByteRepr for Color {
28-
fn to_bytes(&self, buf: &mut [u8]) {
29-
(*self as i32).to_bytes(buf);
30-
}
31-
fn from_bytes(buf: &[u8]) -> Self {
32-
<Color>::from(i32::from_bytes(buf))
33-
}
34-
}
9+
pub type Color = u32;
10+
pub const Color_RED: Color = 0;
11+
pub const Color_GREEN: Color = 1;
12+
pub const Color_BLUE: Color = 2;
3513
pub fn main() {
3614
std::process::exit(main_0());
3715
}
3816
fn main_0() -> i32 {
3917
let n: Value<i32> = Rc::new(RefCell::new(3));
40-
let c: Value<Color> = Rc::new(RefCell::new(Color::from((*n.borrow()))));
41-
return if (((*c.borrow()) as i32) == (Color::BLUE as i32)) {
18+
let c: Value<Color> = Rc::new(RefCell::new(((*n.borrow()) as Color)));
19+
return if (((*c.borrow()) as i32) == (Color_BLUE as i32)) {
4220
0
4321
} else {
4422
1

‎tests/ub/out/refcount/enum_out_of_range_increment.rs‎

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,17 @@ use std::io::prelude::*;
66
use std::io::{Read, Seek, Write};
77
use std::os::fd::AsFd;
88
use std::rc::{Rc, Weak};
9-
#[derive(Clone, Copy, PartialEq, Debug, Default)]
10-
enum color {
11-
#[default]
12-
RED = 0,
13-
GREEN = 1,
14-
BLUE = 2,
15-
}
16-
impl From<i32> for color {
17-
fn from(n: i32) -> color {
18-
match n {
19-
0 => color::RED,
20-
1 => color::GREEN,
21-
2 => color::BLUE,
22-
_ => panic!("invalid color value: {}", n),
23-
}
24-
}
25-
}
26-
libcc2rs::impl_enum_inc_dec!(color);
27-
impl ByteRepr for color {
28-
fn to_bytes(&self, buf: &mut [u8]) {
29-
(*self as i32).to_bytes(buf);
30-
}
31-
fn from_bytes(buf: &[u8]) -> Self {
32-
<color>::from(i32::from_bytes(buf))
33-
}
34-
}
9+
pub type color = u32;
10+
pub const color_RED: color = 0;
11+
pub const color_GREEN: color = 1;
12+
pub const color_BLUE: color = 2;
3513
pub fn main() {
3614
std::process::exit(main_0());
3715
}
3816
fn main_0() -> i32 {
39-
let c: Value<color> = Rc::new(RefCell::new(color::BLUE));
17+
let c: Value<color> = Rc::new(RefCell::new(color_BLUE));
4018
(*c.borrow_mut()).postfix_inc();
41-
return if (((((*c.borrow()) as u32) == ((color::RED as i32) as u32)) as i32) != 0) {
19+
return if (((((*c.borrow()) as u32) == ((color_RED as i32) as u32)) as i32) != 0) {
4220
0
4321
} else {
4422
1

‎tests/ub/out/unsafe/enum_out_of_range_cast.rs‎

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,19 @@ use std::collections::BTreeMap;
66
use std::io::{Read, Seek, Write};
77
use std::os::fd::{AsFd, FromRawFd, IntoRawFd};
88
use std::rc::Rc;
9-
#[derive(Clone, Copy, PartialEq, Debug, Default)]
10-
enum Color {
11-
#[default]
12-
RED = 0,
13-
GREEN = 1,
14-
BLUE = 2,
15-
}
16-
impl From<i32> for Color {
17-
fn from(n: i32) -> Color {
18-
match n {
19-
0 => Color::RED,
20-
1 => Color::GREEN,
21-
2 => Color::BLUE,
22-
_ => panic!("invalid Color value: {}", n),
23-
}
24-
}
25-
}
26-
libcc2rs::impl_enum_inc_dec!(Color);
9+
pub type Color = u32;
10+
pub const Color_RED: Color = 0;
11+
pub const Color_GREEN: Color = 1;
12+
pub const Color_BLUE: Color = 2;
2713
pub fn main() {
2814
unsafe {
2915
std::process::exit(main_0() as i32);
3016
}
3117
}
3218
unsafe fn main_0() -> i32 {
3319
let mut n: i32 = 3;
34-
let mut c: Color = Color::from(n);
35-
return if ((c as i32) == (Color::BLUE as i32)) {
20+
let mut c: Color = ((n) as Color);
21+
return if ((c as i32) == (Color_BLUE as i32)) {
3622
0
3723
} else {
3824
1

‎tests/ub/out/unsafe/enum_out_of_range_increment.rs‎

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,19 @@ use std::collections::BTreeMap;
66
use std::io::{Read, Seek, Write};
77
use std::os::fd::{AsFd, FromRawFd, IntoRawFd};
88
use std::rc::Rc;
9-
#[derive(Clone, Copy, PartialEq, Debug, Default)]
10-
enum color {
11-
#[default]
12-
RED = 0,
13-
GREEN = 1,
14-
BLUE = 2,
15-
}
16-
impl From<i32> for color {
17-
fn from(n: i32) -> color {
18-
match n {
19-
0 => color::RED,
20-
1 => color::GREEN,
21-
2 => color::BLUE,
22-
_ => panic!("invalid color value: {}", n),
23-
}
24-
}
25-
}
26-
libcc2rs::impl_enum_inc_dec!(color);
9+
pub type color = u32;
10+
pub const color_RED: color = 0;
11+
pub const color_GREEN: color = 1;
12+
pub const color_BLUE: color = 2;
2713
pub fn main() {
2814
unsafe {
2915
std::process::exit(main_0() as i32);
3016
}
3117
}
3218
unsafe fn main_0() -> i32 {
33-
let mut c: color = color::BLUE;
19+
let mut c: color = color_BLUE;
3420
c.postfix_inc();
35-
return if ((((c as u32) == ((color::RED as i32) as u32)) as i32) != 0) {
21+
return if ((((c as u32) == ((color_RED as i32) as u32)) as i32) != 0) {
3622
0
3723
} else {
3824
1

0 commit comments

Comments
 (0)