Index: src/cmd/gc/pgen.c |
=================================================================== |
--- a/src/cmd/gc/pgen.c |
+++ b/src/cmd/gc/pgen.c |
@@ -171,6 +171,7 @@ |
if(!debug['N'] || debug['R'] || debug['P']) { |
regopt(ptxt); |
} |
+ expandchecks(ptxt); |
oldstksize = stksize; |
allocauto(ptxt); |
@@ -504,3 +505,22 @@ |
addrescapes(n); |
} |
} |
+ |
+void |
+cgen_checknil(Node *n) |
+{ |
+ Node reg; |
+ |
+ if(disable_checknil) |
+ return; |
+ while(n->op == ODOT || (n->op == OINDEX && isfixedarray(n->left->type->type))) // NOTE: not ODOTPTR |
+ n = n->left; |
+ if(thechar == '5' && n->op != OREGISTER) { |
+ regalloc(®, types[tptr], N); |
+ cgen(n, ®); |
+ gins(ACHECKNIL, ®, N); |
+ regfree(®); |
+ return; |
+ } |
+ gins(ACHECKNIL, n, N); |
+} |