summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Werbeck <simon.werbeck@gmail.com>2014-08-13 02:51:11 +0200
committerJürg Billeter <j@bitron.ch>2014-08-24 13:55:57 +0200
commit57c7d28957ebbc4727584d5e7f102bfa1b71bc65 (patch)
tree00738b668539ad244e1a3505b2b5a4cc2b64e291
parent09aba1e9dc8e121e79bd205fb16bd11821126dba (diff)
downloadvala-57c7d28957ebbc4727584d5e7f102bfa1b71bc65.tar.gz
Make sure type check expression has valid type
Fixes bug 696729
-rw-r--r--codegen/valaccodebasemodule.vala14
1 files changed, 13 insertions, 1 deletions
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index dae33347f..ca282a161 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5456,7 +5456,19 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
public override void visit_type_check (TypeCheck expr) {
generate_type_declaration (expr.type_reference, cfile);
- set_cvalue (expr, create_type_check (get_cvalue (expr.expression), expr.type_reference));
+ var type = expr.expression.value_type;
+ var pointer_type = type as PointerType;
+ if (pointer_type != null) {
+ type = pointer_type.base_type;
+ }
+ var cl = type.data_type as Class;
+ var iface = type.data_type as Interface;
+ if ((cl != null && !cl.is_compact) || iface != null || type is GenericType || type is ErrorType) {
+ set_cvalue (expr, create_type_check (get_cvalue (expr.expression), expr.type_reference));
+ } else {
+ set_cvalue (expr, new CCodeInvalidExpression ());
+ }
+
if (get_cvalue (expr) is CCodeInvalidExpression) {
Report.error (expr.source_reference, "type check expressions not supported for compact classes, structs, and enums");
}