From d918fc429f330325bd331e00aa8930d4a6593704 Mon Sep 17 00:00:00 2001 From: Zihao Yu Date: Mon, 13 Nov 2023 12:04:34 +0800 Subject: [PATCH] tests,alu-tests: fix errors reported by -Wall and -Werror --- tests/alu-tests/Makefile | 2 +- tests/alu-tests/gen_alu_test.c | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/alu-tests/Makefile b/tests/alu-tests/Makefile index 0107c9c..ac9e507 100644 --- a/tests/alu-tests/Makefile +++ b/tests/alu-tests/Makefile @@ -5,7 +5,7 @@ include $(AM_HOME)/Makefile GENERATOR = build/gen_alu_test $(GENERATOR): gen_alu_test.c - gcc -O2 $^ -o $@ + gcc -O2 -Wall -Werror $^ -o $@ $(SRCS): $(GENERATOR) $^ > $@ diff --git a/tests/alu-tests/gen_alu_test.c b/tests/alu-tests/gen_alu_test.c index e4e3843..6c2c907 100644 --- a/tests/alu-tests/gen_alu_test.c +++ b/tests/alu-tests/gen_alu_test.c @@ -7,9 +7,10 @@ /* gcc gen_test.c && ./a.out > test.c && movcc test.c movfusator/lib/softfloat64.o && ./a.out | grep FAIL */ #include +#include -static const double vd[]={-2.0, -1.0, 0.0, 1.0, 2.0}; -static const float vf[]={-2.0f, -1.0f, 0.0f, 1.0f, 2.0f}; +//static const double vd[]={-2.0, -1.0, 0.0, 1.0, 2.0}; +//static const float vf[]={-2.0f, -1.0f, 0.0f, 1.0f, 2.0f}; static const signed int vsi[]={0x80000000, 0x80000001, -2, -1, 0, 1, 2, 0x7ffffffe, 0x7fffffff}; static const signed short vss[]={0x8000, 0x8001, -2, -1, 0, 1, 2, 0x7ffe, 0x7fff}; @@ -82,22 +83,26 @@ static const unsigned char vuc[]={0x80, 0x81, -2, -1, 0, 1, 2, 0x7e, 0x7f}; typedef enum { I, F } type; +static int strsame(const char *s1, const char *s2) { + return strcmp(s1, s2) == 0; +} + int exclude(type t, char* op, int x, int y) { if (t==I) { - if (op=="/" || op=="%") { + if (strsame(op, "/") || strsame(op, "%")) { if (y==0 || (y==-1 && x==0x80000000)) { return 1; } } - else if (op==">>" || op=="<<") { + else if (strsame(op, ">>") || strsame(op, "<<")) { if (y>31 || y<0) { return 1; } } } else if (t==F) { - if (op=="/") { + if (strsame(op, "/")) { if (y==0) { return 1; }