t1 = n->type;
if(t1->sym == S && isptr[t1->etype])
t1 = t1->type;
- if(t1 != T && isptr[t1->etype])
+ if(isptr[t1->etype])
yyerror("embedded type cannot be a pointer");
+ else if(t1->etype == TFORW && t1->embedlineno == 0)
+ t1->embedlineno = lineno;
}
}
int32 bound; // negative is dynamic array
int32 maplineno; // first use of TFORW as map key
+ int32 embedlineno; // first use of TFORW as embedded type
};
#define T ((Type*)0)
void
walkdef(Node *n)
{
- int lno, maplineno;
+ int lno, maplineno, embedlineno;
NodeList *init;
Node *e;
Type *t;
// copy new type and clear fields
// that don't come along
maplineno = n->type->maplineno;
+ embedlineno = n->type->embedlineno;
*n->type = *t;
t = n->type;
t->sym = n->sym;
lineno = maplineno;
maptype(n->type, types[TBOOL]);
}
+ if(embedlineno) {
+ lineno = embedlineno;
+ if(isptr[t->etype])
+ yyerror("embedded type cannot be a pointer");
+ }
break;
}
--- /dev/null
+// errchk $G $D/$F.go
+
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+type T *struct {
+ T; // ERROR "embed.*pointer"
+}