[vala/0.48] codegen: Inline allocated and constant arrays are never NULL
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.48] codegen: Inline allocated and constant arrays are never NULL
- Date: Wed, 15 Jul 2020 07:11:37 +0000 (UTC)
commit e0da25c55274e7af0e68350a9f267e926464b500
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Tue Jul 14 14:13:51 2020 +0200
codegen: Inline allocated and constant arrays are never NULL
Found by -Werror=tautological-pointer-compare
codegen/valaccodebasemodule.vala | 8 ++++++--
codegen/valaccodememberaccessmodule.vala | 2 ++
2 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index c4f9647f9..666b0f067 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -4679,8 +4679,12 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
ccode.add_expression (ccall);
ccode.close ();
} else {
- var ccond = new CCodeConditionalExpression (cnotnull, ccall, cifnull);
- result.cvalue = ccond;
+ if (get_non_null (value)) {
+ result.cvalue = ccall;
+ } else {
+ var ccond = new CCodeConditionalExpression (cnotnull, ccall, cifnull);
+ result.cvalue = ccond;
+ }
result = (GLibValue) store_temp_value (result, node, true);
}
return result;
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index 32e7cf54f..1cec90ac6 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -180,6 +180,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
append_array_length (expr, ccall);
sub += "[0]";
}
+ ((GLibValue) expr.target_value).non_null = true;
}
} else if (expr.symbol_reference is Property) {
var prop = (Property) expr.symbol_reference;
@@ -768,6 +769,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
result.lvalue = false;
}
result.array_size_cvalue = null;
+ result.non_null = array_type.inline_allocated;
} else if (delegate_type != null) {
if (!get_ccode_delegate_target (variable)) {
result.delegate_target_cvalue = new CCodeConstant ("NULL");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]