[SCM] Lisaac compiler branch, mildred-warning-null, updated. lisaac-0.12-631-ga63effe
Mildred Ki'Lya
silkensedai at online.fr
Sat Aug 14 17:22:15 UTC 2010
The following commit has been merged in the mildred-warning-null branch:
commit a63effe60bec31fb53e9a730f942cb49f36c9b62
Author: Mildred Ki'Lya <silkensedai at online.fr>
Date: Sat Mar 13 17:51:07 2010 +0100
Add flag warn-null to check call on NULL sites after flow analysis
In the compiler there are 7 places where a call on NULL can happen sometimes.
These should probably be fixed.
--WARNING----------
Possible call on NULL
Line 39 column 38 in ITM_TYPE_PARAMETER(.../src/item/itm_type_parameter.li):
result := p.parameter_to_type Self;
^
--WARNING----------
Possible call on NULL
Line 364 column 32 in PROFIL(.../src/profil.li):
semantic_error (slot.position,"Recursivity without end.");
^
--WARNING----------
Possible call on NULL
Line 797 column 21 in TYPE(.../src/type/type.li):
tg.generic_list.first.raw.genere_typedef_struct;
^
--WARNING----------
Possible call on NULL
Line 572 column 16 in TYPE(.../src/type/type.li):
tg.generic_list.first.raw.genere_struct;
^
--WARNING----------
Possible call on NULL
Line 777 column 21 in TYPE(.../src/type/type.li):
tg.generic_list.first.raw.genere_typedef_type_c;
^
--WARNING----------
Possible call on NULL
Line 227 column 33 in VARIABLE(.../src/variable/variable.li):
((! is_static) && {wrt.value != NULL} && {! is_executing_pass}).if {
^
--WARNING----------
Possible call on NULL
Line 255 column 16 in VARIABLE(.../src/variable/variable.li):
e.set_create;
^
diff --git a/make.lip.sample b/make.lip.sample
index 53a4a9b..bd3e1f9 100644
--- a/make.lip.sample
+++ b/make.lip.sample
@@ -266,6 +266,12 @@ Section Public
(
is_all_warning := TRUE;
);
+
+ - w_null <-
+ // Warn of every possible NULL call
+ (
+ add_flag "warn-null";
+ );
//
// Optimization.
diff --git a/src/any.li b/src/any.li
index 4db5a7c..c8910d5 100644
--- a/src/any.li
+++ b/src/any.li
@@ -127,6 +127,8 @@ Section Public
- is_statistic:BOOLEAN;
- is_quiet:BOOLEAN;
+ - is_warn_null :BOOLEAN <- ( is_warn_null := LIP_CODE.has_flag "warn-null" );
+
//
//
//
diff --git a/src/code_life/list.li b/src/code_life/list.li
index 7a19baa..6cd4e55 100644
--- a/src/code_life/list.li
+++ b/src/code_life/list.li
@@ -296,7 +296,7 @@ Section Public
(new_expr != NULL).if {
put new_expr to index;
index := index + 1;
- (new_expr = CALL_NULL).if {
+ ( + null:CALL_NULL; (null ?= new_expr) != NULL ).if {
// Delete all ...
{index <= upper}.while_do {
item index.remove;
diff --git a/src/external/call_null.li b/src/external/call_null.li
index 7ec5be3..7f9ac01 100644
--- a/src/external/call_null.li
+++ b/src/external/call_null.li
@@ -32,12 +32,32 @@ Section Inherit
+ parent_instr:Expanded INSTR;
+Section Private
+
+ - warned_list :FAST_ARRAY(POSITION) <-
+ (
+ warned_list := FAST_ARRAY(POSITION).create_with_capacity 8
+ );
+
+ - warned :BOOLEAN <- warned_list.fast_has position;
+
Section Public
- my_copy:SELF <- Self;
- is_necessary:BOOLEAN;
+ - create p:POSITION :SELF <-
+ ( + result :SELF;
+ is_warn_null.if {
+ result := clone;
+ result.set_position p;
+ } else {
+ result := SELF;
+ };
+ result
+ );
+
//
// Remove
//
@@ -69,6 +89,10 @@ Section Public
};
buffer.append code;
is_necessary := TRUE;
+ ((is_warn_null) && {! warned}).if {
+ warning_error (position, "Possible call on NULL");
+ warned_list.add_last position;
+ };
);
//
diff --git a/src/lip/lip_call.li b/src/lip/lip_call.li
index 21f4acb..bc32978 100644
--- a/src/lip/lip_call.li
+++ b/src/lip/lip_call.li
@@ -105,6 +105,12 @@ Section Public
warning_error (position,"No argument for `compiler_version' method.");
};
LISAAC.show_version;
+ }.elseif {name = ALIAS_STR.slot_add_flag} then {
+ str ?= val;
+ (str = NULL).if {
+ semantic_error (position,"String argument needed.");
+ };
+ list_flags.add_last (str.value);
}.elseif {name = ALIAS_STR.slot_path} then {
str ?= val;
(str = NULL).if {
diff --git a/src/lip/lip_code.li b/src/lip/lip_code.li
index 9aecc01..c61aa0a 100644
--- a/src/lip/lip_code.li
+++ b/src/lip/lip_code.li
@@ -33,6 +33,8 @@ Section Inherit
Section Public
+ - list_flags:FAST_ARRAY(STRING_CONSTANT) := FAST_ARRAY(STRING_CONSTANT).create_with_capacity 1;
+
- list_parent:FAST_ARRAY(STRING_CONSTANT) := FAST_ARRAY(STRING_CONSTANT).create_with_capacity 1;
- list_method:FAST_ARRAY(LIP_SLOT_CODE) := FAST_ARRAY(LIP_SLOT_CODE).create_with_capacity 32;
@@ -61,6 +63,11 @@ Section Public
result
);
+ - has_flag flag:ABSTRACT_STRING :BOOLEAN <-
+ (
+ list_flags.fast_has (ALIAS_STR.get flag)
+ );
+
- print_usage <-
( + slot:LIP_SLOT_CODE;
+ is_ok:BOOLEAN;
diff --git a/src/tools/alias_str.li b/src/tools/alias_str.li
index 31ef4f8..10029f7 100644
--- a/src/tools/alias_str.li
+++ b/src/tools/alias_str.li
@@ -178,6 +178,7 @@ Section Public
- slot_get_integer :STRING_CONSTANT := "get_integer";
- slot_get_string :STRING_CONSTANT := "get_string";
- slot_is_cop :STRING_CONSTANT := "is_cop";
+ - slot_add_flag :STRING_CONSTANT := "add_flag";
- c_void :STRING_CONSTANT := "void";
- c_struct :STRING_CONSTANT := "struct __";
@@ -485,6 +486,7 @@ Section Public
list.add slot_get_integer;
list.add slot_get_string;
list.add slot_is_cop;
+ list.add slot_add_flag;
// Type C :
list.add c_void;
diff --git a/src/type/type_null.li b/src/type/type_null.li
index f290378..f651903 100644
--- a/src/type/type_null.li
+++ b/src/type/type_null.li
@@ -68,7 +68,7 @@ Section Public
PUSH.create p context ctext first FALSE
);
};
- lst.add_last CALL_NULL;
+ lst.add_last (CALL_NULL.create p);
);
Section Public
--
Lisaac compiler
More information about the Lisaac-commits
mailing list