Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1106)

Unified Diff: src/cmd/gc/pgen.c

Issue 12970043: code review 12970043: cmd/gc: &x panics if x does (Closed)
Patch Set: diff -r 06602f18d127 https://code.google.com/p/go/ Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/cmd/gc/lex.c ('k') | src/cmd/gc/popt.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(&reg, types[tptr], N);
+ cgen(n, &reg);
+ gins(ACHECKNIL, &reg, N);
+ regfree(&reg);
+ return;
+ }
+ gins(ACHECKNIL, n, N);
+}
« no previous file with comments | « src/cmd/gc/lex.c ('k') | src/cmd/gc/popt.h » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b