-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ondřej Machota <ondrejmachota@gmail.com>
- Loading branch information
Showing
5 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
macro_rules! env { | ||
() => {{}}; | ||
} | ||
|
||
fn main () { | ||
let message = "error message"; | ||
env! (message); // { dg-error "argument must be a string literal" "" } | ||
env! (); // { dg-error "env! takes 1 or 2 arguments" "" } | ||
env! (,); // { dg-error "argument must be a string literal" "" } | ||
env! (1); // { dg-error "argument must be a string literal" "" } | ||
env! ("NOT_DEFINED"); // { dg-error "environment variable 'NOT_DEFINED' not defined" "" } | ||
env! ("NOT_DEFINED",); // { dg-error "environment variable 'NOT_DEFINED' not defined" "" } | ||
env! ("NOT_DEFINED", 1); // { dg-error "argument must be a string literal" "" } | ||
env! ("NOT_DEFINED", "two", "three"); // { dg-error "env! takes 1 or 2 arguments" "" } | ||
env! ("NOT_DEFINED" "expected error message"); // { dg-error "expected token: ','" "" } | ||
env! ("NOT_DEFINED", "expected error message"); // { dg-error "expected error message" "" } | ||
env! ("NOT_DEFINED", "expected error message",); // { dg-error "expected error message" "" } | ||
env! (1, "two"); // { dg-error "argument must be a string literal" "" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// { dg-output "VALUE\nVALUE\n" } | ||
// { dg-set-compiler-env-var ENV_MACRO_TEST "VALUE" } | ||
|
||
macro_rules! env { | ||
() => {{}}; | ||
} | ||
|
||
extern "C" { | ||
fn printf(fmt: *const i8, ...); | ||
} | ||
|
||
fn print(s: &str) { | ||
printf("%s\n" as *const str as *const i8, s as *const str as *const i8); | ||
} | ||
|
||
fn main() -> i32 { | ||
let val0 = env!("ENV_MACRO_TEST"); | ||
|
||
print(val0); | ||
|
||
let val1 = env!("ENV_MACRO_TEST",); | ||
|
||
print(val1); | ||
|
||
0 | ||
} |