mirror of
https://github.com/herumi/xbyak
synced 2024-11-20 16:06:14 -07:00
remove warning of test
This commit is contained in:
parent
e69e0b420a
commit
5fc69fc8e2
3 changed files with 18 additions and 31 deletions
|
@ -1,5 +1,4 @@
|
|||
#include <stdio.h>
|
||||
#define XBYAK_NO_OP_NAMES
|
||||
#include "xbyak/xbyak.h"
|
||||
#include "xbyak/xbyak_bin2hex.h"
|
||||
#include <stdlib.h>
|
||||
|
@ -897,7 +896,7 @@ class Test {
|
|||
for (size_t j = 0; j < NUM_OF_ARRAY(sufTbl); j++) {
|
||||
if (!(p->mode & (1 << j))) continue;
|
||||
char buf[16];
|
||||
sprintf(buf, "%s%s", p->name, sufTbl[j].name);
|
||||
snprintf(buf, sizeof(buf), "%s%s", p->name, sufTbl[j].name);
|
||||
if (p->hasImm) {
|
||||
put(buf, XMM, XMM|MEM, IMM);
|
||||
} else {
|
||||
|
@ -984,7 +983,9 @@ class Test {
|
|||
}
|
||||
void putCmov() const
|
||||
{
|
||||
const char tbl[][4] = {
|
||||
const struct {
|
||||
const char *s;
|
||||
} tbl[] = {
|
||||
"o",
|
||||
"no",
|
||||
"b",
|
||||
|
@ -1017,12 +1018,12 @@ class Test {
|
|||
"g",
|
||||
};
|
||||
for (size_t i = 0; i < NUM_OF_ARRAY(tbl); i++) {
|
||||
char buf[16];
|
||||
sprintf(buf, "cmov%s", tbl[i]);
|
||||
char buf[32];
|
||||
snprintf(buf, sizeof(buf), "cmov%s", tbl[i].s);
|
||||
put(buf, REG16, REG16|MEM);
|
||||
put(buf, REG32, REG32|MEM);
|
||||
put(buf, REG64, REG64|MEM);
|
||||
sprintf(buf, "set%s", tbl[i]);
|
||||
snprintf(buf, sizeof(buf), "set%s", tbl[i].s);
|
||||
put(buf, REG8|REG8_3|MEM);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <stdio.h>
|
||||
#define XBYAK_NO_OP_NAMES
|
||||
#define XBYAK_ENABLE_OMITTED_OPERAND
|
||||
#include "xbyak/xbyak.h"
|
||||
#define CYBOZU_TEST_DISABLE_AUTO_RUN
|
||||
#include "cybozu/test.hpp"
|
||||
|
||||
using namespace Xbyak;
|
||||
|
||||
|
@ -15,39 +16,24 @@ public:
|
|||
#include "nm.cpp"
|
||||
};
|
||||
|
||||
#define _STR(x) #x
|
||||
#define TEST(syntax) err = true; try { syntax; err = false; } catch (Xbyak::Error) { } catch (...) { } if (!err) printf("should be err:%s;\n", _STR(syntax))
|
||||
|
||||
class ErrorSample : public CodeGenerator {
|
||||
void operator=(const ErrorSample&);
|
||||
public:
|
||||
void gen()
|
||||
{
|
||||
bool err;
|
||||
TEST(mov(ptr[eax],1));
|
||||
TEST(test(ptr[eax],1));
|
||||
TEST(adc(ptr[eax],1));
|
||||
TEST(setz(eax));
|
||||
CYBOZU_TEST_EXCEPTION(mov(ptr[eax],1), std::exception);
|
||||
CYBOZU_TEST_EXCEPTION(test(ptr[eax],1), std::exception);
|
||||
CYBOZU_TEST_EXCEPTION(adc(ptr[eax],1), std::exception);
|
||||
CYBOZU_TEST_EXCEPTION(setz(eax), std::exception);
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
try
|
||||
{
|
||||
size_t size = sizeof(Xbyak::Operand);
|
||||
if (size != 4) {
|
||||
printf("sizeof Operand %d\n", (int)size);
|
||||
}
|
||||
try {
|
||||
Sample s;
|
||||
s.gen();
|
||||
} catch (std::exception& e) {
|
||||
printf("ERR:%s\n", e.what());
|
||||
} catch (...) {
|
||||
printf("unknown error\n");
|
||||
}
|
||||
CYBOZU_TEST_EQUAL(sizeof(Xbyak::Operand), 4u);
|
||||
Sample s;
|
||||
s.gen();
|
||||
ErrorSample es;
|
||||
es.gen();
|
||||
} catch (std::exception& e) {
|
||||
printf("err %s\n", e.what());
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
@echo off
|
||||
set OPT=/EHsc -I../xbyak /W4 -D_CRT_SECURE_NO_WARNINGS /nologo
|
||||
set OPT=/EHsc -I../xbyak -I./ /W4 -D_CRT_SECURE_NO_WARNINGS /nologo
|
Loading…
Reference in a new issue