[vala/staging] codegen: Inline allocated and constant arrays are never NULL
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] codegen: Inline allocated and constant arrays are never NULL
- Date: Tue, 14 Jul 2020 12:15:07 +0000 (UTC)
commit 46d5fb8ffcf35f84b8b3a71f954fcc514d00752b
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 5d70d5b49..26ddcb7b8 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -4706,8 +4706,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]