* net/loveruby/cflat/compiler/TypeChecker.java: better error message.

* test/test.sh: run following tests.
* test/deref-semcheck1.cb: check if dereferencing int causes compile error.
* test/deref-semcheck2.cb: check if dereferencing char causes compile error.
* test/deref-semcheck3.cb: check if dereferencing struct causes compile error.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3767 1b9489fe-b721-0410-924e-b54b9192deb8
This commit is contained in:
Minero Aoki 2008-01-01 16:32:15 +00:00
parent 705818d1dc
commit 1dedd1d283
6 changed files with 33 additions and 5 deletions

View File

@ -1,3 +1,19 @@
Wed Jan 2 01:32:12 2008 Minero Aoki <aamine@loveruby.net>
* net/loveruby/cflat/compiler/TypeChecker.java: better error
message.
* test/test.sh: run following tests.
* test/deref-semcheck1.cb: check if dereferencing int causes
compile error.
* test/deref-semcheck2.cb: check if dereferencing char causes
compile error.
* test/deref-semcheck3.cb: check if dereferencing struct causes
compile error.
Wed Jan 2 01:24:05 2008 Minero Aoki <aamine@loveruby.net>
* net/loveruby/cflat/compiler/TypeChecker.java: check member

View File

@ -394,16 +394,17 @@ class TypeChecker extends Visitor {
}
protected void incompatibleTypeError(Type l, Type r) {
errorHandler.error("incompatible type: " +
l.textize() + " and " + r.textize());
errorHandler.error("incompatible type: "
+ l.textize() + " and " + r.textize());
}
protected void notIntegerError(Type type) {
errorHandler.error("non-integer argument for unary op: " +
type.textize());
errorHandler.error("non-integer argument for unary op: "
+ type.textize());
}
protected void notPointerError(Type type) {
errorHandler.error("non-pointer argument: " + type.textize());
errorHandler.error("dereferencing non-pointer expression: "
+ type.textize());
}
}

1
test/deref-semcheck1.cb Normal file
View File

@ -0,0 +1 @@
int main(int argc, char **argv) { return *1; }

1
test/deref-semcheck2.cb Normal file
View File

@ -0,0 +1 @@
int main(int argc, char **argv) { return *'c'; }

6
test/deref-semcheck3.cb Normal file
View File

@ -0,0 +1,6 @@
struct st { int x; };
int main(int argc, char **argv) {
struct st s;
return *s;
}

View File

@ -135,6 +135,9 @@ assert_error $CBC union-semcheck6.cb
assert_out "5;5" ./pointer
assert_out "1;2" ./ptrmemb
assert_error $CBC deref-semcheck1.cb
assert_error $CBC deref-semcheck2.cb
assert_error $CBC deref-semcheck3.cb
assert_out "2;64;-128;0" ./charops
assert_out "2;64;128;0" ./ucharops