From: Simon Werbeck Date: Wed, 13 Aug 2014 00:51:11 +0000 (+0200) Subject: Make sure type check expression has valid type X-Git-Tag: 0.25.2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=57c7d28957ebbc4727584d5e7f102bfa1b71bc65;p=thirdparty%2Fvala.git Make sure type check expression has valid type Fixes bug 696729 --- 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"); }