Skip to content

Commit

Permalink
Ensure examples don't fail to compile on aarch64 during testing, and …
Browse files Browse the repository at this point in the history
…add explicit error messages for old-style directives.
  • Loading branch information
CensoredUsername committed Oct 9, 2024
1 parent ce3787d commit e7290dd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 8 additions & 4 deletions build_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,17 @@ do
"./testing/tests/${TARGET}.rs"
fi
if [ -f "./doc/examples/${EX}/src/x64.rs" ]; then
cp "./doc/examples/${EX}/src/x64.rs" "./testing/tests/${TARGET}_x64.rs"
echo -n -e "#[cfg(target_arch=\"x64\")]\n#[test]\nfn ex_${TARGET}()\n{\n main();\n}\n" >> \
echo -n -e "#[cfg(target_arch=\"x86_64\")]\nmod test {\n" > \
"./testing/tests/${TARGET}_x64.rs"
cat "./doc/examples/${EX}/src/x64.rs" >> "./testing/tests/${TARGET}_x64.rs"
echo -n -e "\n#[test]\nfn ex_${TARGET}()\n{\n main();\n}\n}\n" >> \
"./testing/tests/${TARGET}_x64.rs"
fi
if [ -f "./doc/examples/${EX}/src/aarch64.rs" ]; then
cp "./doc/examples/${EX}/src/aarch64.rs" "./testing/tests/${TARGET}_aarch64.rs"
echo -n -e "#[cfg(target_arch=\"aarch64\")]\n#[test]\nfn ex_${TARGET}()\n{\n main();\n}\n" >> \
echo -n -e "#[cfg(target_arch=\"aarch64\")]\nmod test {\n" > \
"./testing/tests/${TARGET}_aarch64.rs"
cat "./doc/examples/${EX}/src/aarch64.rs" >> "./testing/tests/${TARGET}_aarch64.rs"
echo -n -e "\n#[test]\nfn ex_${TARGET}()\n{\n main();\n}\n}\n" >> \
"./testing/tests/${TARGET}_aarch64.rs"
fi
done
Expand Down
6 changes: 6 additions & 0 deletions plugin/src/directive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ pub(crate) fn evaluate_directive(invocation_context: &mut DynasmContext, stmts:
}
}
},
// these are deprecated, but to prevent bad error messages handle them explicitly
// I'd like to provide a warning instead, but proc-macro-error2 emit_warning! seems to not work.
"byte" => emit_error!(directive.span(), "Directive .byte is deprecated, please use .i8 or .u8 instead."),
"word" => emit_error!(directive.span(), "Directive .word is deprecated, please use .i16 or .u16 instead."),
"dword" => emit_error!(directive.span(), "Directive .dword is deprecated, please use .i32 or .u32 instead."),
"qword" => emit_error!(directive.span(), "Directive .qword is deprecated, please use .i64 or .u64 instead."),
d => {
// unknown directive. skip ahead until we hit a ; so the parser can recover
emit_error!(directive, "unknown directive '{}'", d);
Expand Down

0 comments on commit e7290dd

Please sign in to comment.