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

Delta Between Two Patch Sets: src/cmd/gc/typecheck.c

Issue 4548073: code review 4548073: gc: disallow ... in type conversions (Closed)
Left Patch Set: Created 13 years, 9 months ago
Right Patch Set: diff -r b0c691bce96b https://go.googlecode.com/hg/ Created 13 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | test/ddd1.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 /* 5 /*
6 * type check the whole tree of an expression. 6 * type check the whole tree of an expression.
7 * calculates expression types. 7 * calculates expression types.
8 * evaluates compile time constants. 8 * evaluates compile time constants.
9 * marks variables that escape the local frame. 9 * marks variables that escape the local frame.
10 * rewrites n->op to be more specific in some cases. 10 * rewrites n->op to be more specific in some cases.
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 yyerror("invalid use of ... with builtin %#N", l ); 787 yyerror("invalid use of ... with builtin %#N", l );
788 // builtin: OLEN, OCAP, etc. 788 // builtin: OLEN, OCAP, etc.
789 n->op = l->etype; 789 n->op = l->etype;
790 n->left = n->right; 790 n->left = n->right;
791 n->right = N; 791 n->right = N;
792 goto reswitch; 792 goto reswitch;
793 } 793 }
794 defaultlit(&n->left, T); 794 defaultlit(&n->left, T);
795 l = n->left; 795 l = n->left;
796 if(l->op == OTYPE) { 796 if(l->op == OTYPE) {
797 » » » if(n->isddd) 797 » » » if(n->isddd || l->type->bound == -100)
798 yyerror("invalid use of ... in type conversion", l); 798 yyerror("invalid use of ... in type conversion", l);
799 // pick off before type-checking arguments 799 // pick off before type-checking arguments
800 ok |= Erv; 800 ok |= Erv;
801 // turn CALL(type, arg) into CONV(arg) w/ type 801 // turn CALL(type, arg) into CONV(arg) w/ type
802 n->left = N; 802 n->left = N;
803 n->op = OCONV; 803 n->op = OCONV;
804 n->type = l->type; 804 n->type = l->type;
805 if(onearg(n, "conversion to %T", l->type) < 0) 805 if(onearg(n, "conversion to %T", l->type) < 0)
806 goto error; 806 goto error;
807 goto doconv; 807 goto doconv;
(...skipping 1699 matching lines...) Expand 10 before | Expand all | Expand 10 after
2507 return n->type; 2507 return n->type;
2508 2508
2509 // Check for ntype cycle. 2509 // Check for ntype cycle.
2510 if((f2 = resolve(f2)) != N && (f1 = resolve(f2->ntype)) != N) { 2510 if((f2 = resolve(f2)) != N && (f1 = resolve(f2->ntype)) != N) {
2511 f2 = resolve(f1->ntype); 2511 f2 = resolve(f1->ntype);
2512 if(f1 == n || f2 == n) 2512 if(f1 == n || f2 == n)
2513 return T; 2513 return T;
2514 } 2514 }
2515 } 2515 }
2516 } 2516 }
LEFTRIGHT
« no previous file | test/ddd1.go » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

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