aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-11-02 11:48:06 +0000
committerPhilip Herron <philip.herron@embecosm.com>2021-11-02 11:48:06 +0000
commitfc5f8d746362a42adc52e538dec248bd2992a794 (patch)
treec49825727c7726769f7226e3ed8b3697192cb7d3 /gcc
parente3defa10bc63ba3f81da00fc322b5b1e0d1717ed (diff)
downloadgcc-fc5f8d746362a42adc52e538dec248bd2992a794.zip
gcc-fc5f8d746362a42adc52e538dec248bd2992a794.tar.gz
gcc-fc5f8d746362a42adc52e538dec248bd2992a794.tar.bz2
Default type checking on CallExpr's to TyTy::ErrorType
It is ok for type checking to error/fail on a construct within the crate, we can try our best to continue on to find as many errors as possible. To achieve this without running into nullptr's we can use the ErrorType node to signify an error. This also cleans up alot of noise in our error handling.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/typecheck/rust-tyty-call.h3
-rw-r--r--gcc/testsuite/rust/compile/func2.rs2
-rw-r--r--gcc/testsuite/rust/compile/func3.rs2
-rw-r--r--gcc/testsuite/rust/compile/tuple_struct1.rs2
-rw-r--r--gcc/testsuite/rust/compile/tuple_struct2.rs2
-rw-r--r--gcc/testsuite/rust/compile/tuple_struct3.rs2
6 files changed, 2 insertions, 11 deletions
diff --git a/gcc/rust/typecheck/rust-tyty-call.h b/gcc/rust/typecheck/rust-tyty-call.h
index 9ff5f6f..c11fd4d 100644
--- a/gcc/rust/typecheck/rust-tyty-call.h
+++ b/gcc/rust/typecheck/rust-tyty-call.h
@@ -71,7 +71,8 @@ public:
private:
TypeCheckCallExpr (HIR::CallExpr &c, TyTy::VariantDef &variant,
Resolver::TypeCheckContext *context)
- : resolved (nullptr), call (c), variant (variant), context (context),
+ : resolved (new TyTy::ErrorType (c.get_mappings ().get_hirid ())), call (c),
+ variant (variant), context (context),
mappings (Analysis::Mappings::get ())
{}
diff --git a/gcc/testsuite/rust/compile/func2.rs b/gcc/testsuite/rust/compile/func2.rs
index 219bbfe..0b8d999 100644
--- a/gcc/testsuite/rust/compile/func2.rs
+++ b/gcc/testsuite/rust/compile/func2.rs
@@ -4,6 +4,4 @@ fn test(a: i32, b: i32) -> i32 {
fn main() {
let a = test(1); // { dg-error "unexpected number of arguments 1 expected 2" }
- // { dg-error "failed to lookup type to CallExpr" "" { target *-*-* } .-1 }
- // { dg-error "failed to type resolve expression" "" { target *-*-* } .-2 }
}
diff --git a/gcc/testsuite/rust/compile/func3.rs b/gcc/testsuite/rust/compile/func3.rs
index 3ab374a..2a32947 100644
--- a/gcc/testsuite/rust/compile/func3.rs
+++ b/gcc/testsuite/rust/compile/func3.rs
@@ -6,6 +6,4 @@ fn main() {
let a = test(1, true);
// { dg-error "expected .i32. got .bool." "" { target *-*-* } .-1 }
// { dg-error "Type Resolution failure on parameter" "" { target *-*-* } .-2 }
- // { dg-error "failed to lookup type to CallExpr" "" { target *-*-* } .-3 }
- // { dg-error "failed to type resolve expression" "" { target *-*-* } .-4 }
}
diff --git a/gcc/testsuite/rust/compile/tuple_struct1.rs b/gcc/testsuite/rust/compile/tuple_struct1.rs
index c382909..2f4cb4a 100644
--- a/gcc/testsuite/rust/compile/tuple_struct1.rs
+++ b/gcc/testsuite/rust/compile/tuple_struct1.rs
@@ -5,6 +5,4 @@ struct Foo {
fn main() {
let a = Foo(1, 2); // { dg-error "expected function, tuple struct or tuple variant, found struct 'Foo'" }
- // { dg-error "failed to lookup type to CallExpr" "" { target *-*-* } .-1 }
- // { dg-error "failed to type resolve expression" "" { target *-*-* } .-2 }
}
diff --git a/gcc/testsuite/rust/compile/tuple_struct2.rs b/gcc/testsuite/rust/compile/tuple_struct2.rs
index dba0511..1fc1896 100644
--- a/gcc/testsuite/rust/compile/tuple_struct2.rs
+++ b/gcc/testsuite/rust/compile/tuple_struct2.rs
@@ -2,6 +2,4 @@ struct Bar(i32, i32, bool);
fn main() {
let a = Bar(1, 2); // { dg-error "unexpected number of arguments 2 expected 3" }
- // { dg-error "failed to lookup type to CallExpr" "" { target *-*-* } .-1 }
- // { dg-error "failed to type resolve expression" "" { target *-*-* } .-2 }
}
diff --git a/gcc/testsuite/rust/compile/tuple_struct3.rs b/gcc/testsuite/rust/compile/tuple_struct3.rs
index a70306d..4af66b8 100644
--- a/gcc/testsuite/rust/compile/tuple_struct3.rs
+++ b/gcc/testsuite/rust/compile/tuple_struct3.rs
@@ -3,6 +3,4 @@ struct Foo(i32, i32, bool);
fn main() {
let c = Foo(1, 2f32, true);
// { dg-error "expected .i32. got .f32." "" { target *-*-* } .-1 }
- // { dg-error "failed to lookup type to CallExpr" "" { target *-*-* } .-2 }
- // { dg-error "failed to type resolve expression" "" { target *-*-* } .-3 }
}