From: Juerg Billeter Date: Sat, 19 Apr 2008 07:30:12 +0000 (+0000) Subject: disable null warnings with --disable-non-null X-Git-Tag: VALA_0_3_1~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70bbd52fe4746a91d2a4932cfaf082e22ccbffe8;p=thirdparty%2Fvala.git disable null warnings with --disable-non-null 2008-04-19 Juerg Billeter * vala/valasemanticanalyzer.vala: disable null warnings with --disable-non-null svn path=/trunk/; revision=1264 --- diff --git a/ChangeLog b/ChangeLog index d685209b2..c192a73dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-04-19 Jürg Billeter + + * vala/valasemanticanalyzer.vala: disable null warnings with + --disable-non-null + 2008-04-19 Jürg Billeter * vapi/packages/gio-2.0/: fix g_output_stream_write_all and diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala index 6b6accebf..dc7e2f200 100644 --- a/vala/valasemanticanalyzer.vala +++ b/vala/valasemanticanalyzer.vala @@ -547,13 +547,11 @@ public class Vala.SemanticAnalyzer : CodeVisitor { public override void visit_formal_parameter (FormalParameter p) { p.accept_children (this); - if (p.default_expression != null) { + if (context.non_null && p.default_expression != null) { if (p.default_expression is NullLiteral && !p.type_reference.nullable && p.direction != ParameterDirection.OUT) { - p.error = true; - Report.error (p.source_reference, "`null' incompatible with parameter type `%s`".printf (p.type_reference.to_string ())); - return; + Report.warning (p.source_reference, "`null' incompatible with parameter type `%s`".printf (p.type_reference.to_string ())); } } @@ -1172,7 +1170,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { Report.warning (stmt.source_reference, "Local variable with strong reference used as return value and method return type hasn't been declared to transfer ownership"); } - if (stmt.return_expression is NullLiteral + if (context.non_null && stmt.return_expression is NullLiteral && !current_return_type.nullable) { Report.warning (stmt.source_reference, "`null' incompatible with return type `%s`".printf (current_return_type.to_string ())); } @@ -1868,7 +1866,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { expr.error = true; Report.error (arg.source_reference, "Argument %d: Cannot pass null to reference parameter".printf (i + 1)); return false; - } else if (param.direction != ParameterDirection.OUT && !param.type_reference.nullable) { + } else if (context.non_null && param.direction != ParameterDirection.OUT && !param.type_reference.nullable) { Report.warning (arg.source_reference, "Argument %d: Cannot pass null to non-null parameter type".printf (i + 1)); } } else if (arg_type == 1) {