Fix assertion when returning intermediate types.
The fuzzer managed to trigger an assertion by returning an invalid type from a void function. We were neglecting to clear out the expression when reporting it as invalid, leaving it for `checkValid` to find later. Change-Id: Icc152c867a3316fe994967e192601fb4d10da98f Bug: oss-fuzz:37704 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/442678 Commit-Queue: John Stiles <johnstiles@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
parent
bb8cf5804c
commit
537c8a7ad5
@ -1 +1,3 @@
|
||||
void main() { return true; }
|
||||
void a() { return true; }
|
||||
void b() { return b; }
|
||||
void c() { return int; }
|
||||
|
@ -801,6 +801,7 @@ std::unique_ptr<Block> IRGenerator::finalizeFunction(const FunctionDeclaration&
|
||||
std::move(returnStmt.expression()), returnType));
|
||||
} else {
|
||||
// Returning something from a function with a void return type.
|
||||
returnStmt.setExpression(nullptr);
|
||||
fIRGenerator->errorReporter().error(returnStmt.fOffset,
|
||||
"may not return a value from a void function");
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
### Compilation failed:
|
||||
|
||||
error: 1: may not return a value from a void function
|
||||
1 error
|
||||
error: 2: may not return a value from a void function
|
||||
error: 3: may not return a value from a void function
|
||||
3 errors
|
||||
|
Loading…
Reference in New Issue
Block a user