File tree Expand file tree Collapse file tree 3 files changed +107
-0
lines changed
gcc/testsuite/rust/execute/xfail Expand file tree Collapse file tree 3 files changed +107
-0
lines changed Original file line number Diff line number Diff line change
1
+ // { dg-output "macro\nmacro\nmacro\nmacro\n" }
2
+ extern "C" {
3
+ fn printf ( s : * const i8 , ...) ;
4
+ }
5
+
6
+ fn f ( ) {
7
+ let r_s = "macro\n \0 " ;
8
+ let s_p = r_s as * const str ;
9
+ let c_p = s_p as * const i8 ;
10
+
11
+ printf ( c_p) ;
12
+ }
13
+
14
+ macro_rules! empty0 {
15
+ ( ) => ( f( ) ) ;
16
+ }
17
+
18
+ macro_rules! empty1 {
19
+ { } => { f( ) } ;
20
+ }
21
+
22
+ macro_rules! empty2 {
23
+ [ ] => [ f( ) ] ;
24
+ }
25
+
26
+ // using multiple parens/brackets/curlies variants allows us to make sure we
27
+ // parse everything properly
28
+ fn main ( ) {
29
+ empty0 ! ( ) ;
30
+ empty1 ! { } ;
31
+ empty2 ! [ ] ;
32
+ }
Original file line number Diff line number Diff line change
1
+ // { dg-output "arg\narg\n" }
2
+ extern "C" {
3
+ fn printf ( s : * const i8 , ...) ;
4
+ }
5
+
6
+ fn f ( ) {
7
+ let r_s = "arg\n \0 " ;
8
+ let s_p = r_s as * const str ;
9
+ let c_p = s_p as * const i8 ;
10
+
11
+ printf ( c_p) ;
12
+ }
13
+
14
+ macro_rules! kw0 {
15
+ ( keyword) => { f( ) } ;
16
+ }
17
+
18
+ macro_rules! kw1 {
19
+ ( fn ) => { f( ) } ;
20
+ }
21
+
22
+ macro_rules! kw2 {
23
+ ( kw0 kw1 kw3) => { f( ) } ;
24
+ }
25
+
26
+ fn main ( ) {
27
+ kw0 ! ( keyword) ;
28
+ kw1 ! ( fn ) ;
29
+ kw2 ! ( kw0 kw1 kw3) ;
30
+ }
Original file line number Diff line number Diff line change
1
+ // { dg-output "invok\ninvok\ninvok\ninvok\ninvok\n" }
2
+ extern "C" {
3
+ fn printf ( s : * const i8 , ...) ;
4
+ }
5
+
6
+ fn f ( ) {
7
+ let r_s = "invok\n \0 " ;
8
+ let s_p = r_s as * const str ;
9
+ let c_p = s_p as * const i8 ;
10
+
11
+ printf ( c_p) ;
12
+ }
13
+
14
+ macro_rules! invocation0 {
15
+ ( valid) => { f( ) } ;
16
+ ( ) => { } ;
17
+ }
18
+
19
+ macro_rules! invocation1 {
20
+ ( valid) => { } ;
21
+ ( ) => { f( ) } ;
22
+ }
23
+
24
+ macro_rules! invocation2 {
25
+ ( valid) => { f( ) } ;
26
+ ( invalid) => { } ;
27
+ }
28
+
29
+ macro_rules! invocation3 {
30
+ ( this is a valid invocation) => { f( ) } ;
31
+ ( not this one) => { } ;
32
+ }
33
+
34
+ macro_rules! invocation4 {
35
+ ( fn f( ) { } ) => { f( ) } ;
36
+ ( not a keyword) => { } ;
37
+ }
38
+
39
+ fn main ( ) {
40
+ invocation0 ! ( valid) ;
41
+ invocation1 ! ( ) ;
42
+ invocation2 ! ( valid) ;
43
+ invocation3 ! ( this is a valid invocation) ;
44
+ invocation4 ! ( fn f( ) { } ) ;
45
+ }
You can’t perform that action at this time.
0 commit comments