]> Cypherpunks repositories - gostls13.git/commitdiff
bug132
authorRuss Cox <rsc@golang.org>
Tue, 25 Aug 2009 00:06:10 +0000 (17:06 -0700)
committerRuss Cox <rsc@golang.org>
Tue, 25 Aug 2009 00:06:10 +0000 (17:06 -0700)
R=ken
OCL=33792
CL=33803

src/cmd/gc/dcl.c
test/fixedbugs/bug132.go [moved from test/bugs/bug132.go with 95% similarity]
test/golden.out

index 559cd8d0ad656065b217aa1db6e3910e35d918ae..96a87eeff9f2d495e7a3b315db6612f455efe350 100644 (file)
@@ -752,12 +752,13 @@ ok:
 Type**
 stotype(NodeList *l, int et, Type **t)
 {
-       Type *f, *t1;
+       Type *f, *t1, **t0;
        Strlit *note;
        int lno;
        NodeList *init;
        Node *n;
 
+       t0 = t;
        init = nil;
        lno = lineno;
        for(; l; l=l->next) {
@@ -837,6 +838,14 @@ stotype(NodeList *l, int et, Type **t)
                        f->sym = f->nname->sym;
                        if(pkgimportname != S && !exportname(f->sym->name))
                                f->sym = pkglookup(f->sym->name, structpkg);
+                       if(f->sym) {
+                               for(t1=*t0; t1!=T; t1=t1->down) {
+                                       if(t1->sym == f->sym) {
+                                               yyerror("duplicate field %s", t1->sym->name);
+                                               break;
+                                       }
+                               }
+                       }
                }
 
                *t = f;
similarity index 95%
rename from test/bugs/bug132.go
rename to test/fixedbugs/bug132.go
index 58bbe077eca94acbdf94a5f57e82253aa4ed5541..13a054e1c2a86ed06463d8ca6e0e8550512ed02c 100644 (file)
@@ -1,4 +1,4 @@
-// ! $G $D/$F.go || echo BUG: compilation succeeds incorrectly
+// errchk $G $D/$F.go
 
 // Copyright 2009 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
@@ -7,7 +7,7 @@
 package main
 
 type T struct {
-       x, x int  // this should be a compile-time error
+       x, x int  // ERROR "duplicate"
 }
 
 /*
@@ -18,7 +18,7 @@ tume error at the declaration point.
 
 /* Condensed e-mail thread:
 
----------- Russ Cox    
+---------- Russ Cox
 I don't think this is an error as long as you don't refer to x. I like the fact that you could name
 multiple elements in the struct "pad".
 
index f3d59679ba3ed2d35442060fd27f9ff4aecf387a..7aac0e1fc5d343ffcfdd732097c1a2b5007cf1cf 100644 (file)
@@ -141,9 +141,6 @@ panic PC=xxx
 
 == bugs/
 
-=========== bugs/bug132.go
-BUG: compilation succeeds incorrectly
-
 =========== bugs/bug136.go
 BUG: errchk: command succeeded unexpectedly