Commit 3ffd29fb authored by Russ Cox's avatar Russ Cox

cmd/cc, runtime: disallow structs without tags

Structs without tags have no unique name to use in the
Go definitions generated from the C types.
This caused issue 8812, fixed by CL 149260043.
Avoid future problems by requiring struct tags.

Update runtime as needed.
(There is no other C code in the tree.)

LGTM=bradfitz, iant
R=golang-codereviews, bradfitz, dave, iant
CC=golang-codereviews, khr, r
https://golang.org/cl/150360043
parent c65a47f8
...@@ -1043,6 +1043,7 @@ complex: ...@@ -1043,6 +1043,7 @@ complex:
} }
| LSTRUCT sbody | LSTRUCT sbody
{ {
diag(Z, "struct must have tag");
taggen++; taggen++;
sprint(symb, "_%d_", taggen); sprint(symb, "_%d_", taggen);
$$ = dotag(lookup(), TSTRUCT, autobn); $$ = dotag(lookup(), TSTRUCT, autobn);
......
This diff is collapsed.
/* A Bison parser, made by GNU Bison 2.7.12-4996. */ /* A Bison parser, made by GNU Bison 2.3. */
/* Bison interface for Yacc-like parsers in C /* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation; either version 2, or (at your option)
(at your option) any later version. any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, you may create a larger work that contains /* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work part or all of the Bison parser skeleton and distribute that work
...@@ -26,20 +29,10 @@ ...@@ -26,20 +29,10 @@
special exception, which will cause the skeleton and the resulting special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public Bison output files to be licensed under the GNU General Public
License without this special exception. License without this special exception.
This special exception was added by the Free Software Foundation in This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */ version 2.2 of Bison. */
#ifndef YY_YY_Y_TAB_H_INCLUDED
# define YY_YY_Y_TAB_H_INCLUDED
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int yydebug;
#endif
/* Tokens. */ /* Tokens. */
#ifndef YYTOKENTYPE #ifndef YYTOKENTYPE
# define YYTOKENTYPE # define YYTOKENTYPE
...@@ -196,12 +189,11 @@ extern int yydebug; ...@@ -196,12 +189,11 @@ extern int yydebug;
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE typedef union YYSTYPE
{
/* Line 2053 of yacc.c */
#line 36 "cc.y" #line 36 "cc.y"
{
Node* node; Node* node;
Sym* sym; Sym* sym;
Type* type; Type* type;
...@@ -225,30 +217,14 @@ typedef union YYSTYPE ...@@ -225,30 +217,14 @@ typedef union YYSTYPE
int32 lval; int32 lval;
double dval; double dval;
vlong vval; vlong vval;
}
/* Line 1529 of yacc.c. */
/* Line 2053 of yacc.c */ #line 223 "y.tab.h"
#line 232 "y.tab.h" YYSTYPE;
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif #endif
extern YYSTYPE yylval; extern YYSTYPE yylval;
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int yyparse (void *YYPARSE_PARAM);
#else
int yyparse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int yyparse (void);
#else
int yyparse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !YY_YY_Y_TAB_H_INCLUDED */
...@@ -273,7 +273,8 @@ struct MStats ...@@ -273,7 +273,8 @@ struct MStats
bool debuggc; bool debuggc;
// Statistics about allocation size classes. // Statistics about allocation size classes.
struct {
struct MStatsBySize {
uint32 size; uint32 size;
uint64 nmalloc; uint64 nmalloc;
uint64 nfree; uint64 nfree;
...@@ -282,6 +283,7 @@ struct MStats ...@@ -282,6 +283,7 @@ struct MStats
uint64 tinyallocs; // number of tiny allocations that didn't cause actual allocation; not exported to Go directly uint64 tinyallocs; // number of tiny allocations that didn't cause actual allocation; not exported to Go directly
}; };
#define mstats runtime·memstats #define mstats runtime·memstats
extern MStats mstats; extern MStats mstats;
void runtime·updatememstats(GCStats *stats); void runtime·updatememstats(GCStats *stats);
...@@ -489,7 +491,7 @@ struct MHeap ...@@ -489,7 +491,7 @@ struct MHeap
// the padding makes sure that the MCentrals are // the padding makes sure that the MCentrals are
// spaced CacheLineSize bytes apart, so that each MCentral.lock // spaced CacheLineSize bytes apart, so that each MCentral.lock
// gets its own cache line. // gets its own cache line.
struct { struct MHeapCentral {
MCentral mcentral; MCentral mcentral;
byte pad[CacheLineSize]; byte pad[CacheLineSize];
} central[NumSizeClasses]; } central[NumSizeClasses];
......
...@@ -63,7 +63,7 @@ typedef struct Tos Tos; ...@@ -63,7 +63,7 @@ typedef struct Tos Tos;
typedef intptr _Plink; typedef intptr _Plink;
struct Tos { struct Tos {
struct /* Per process profiling */ struct TosProf /* Per process profiling */
{ {
_Plink *pp; /* known to be 0(ptr) */ _Plink *pp; /* known to be 0(ptr) */
_Plink *next; /* known to be 4(ptr) */ _Plink *next; /* known to be 4(ptr) */
......
...@@ -2421,7 +2421,7 @@ runtime·mcount(void) ...@@ -2421,7 +2421,7 @@ runtime·mcount(void)
return runtime·sched.mcount; return runtime·sched.mcount;
} }
static struct { static struct ProfState {
uint32 lock; uint32 lock;
int32 hz; int32 hz;
} prof; } prof;
......
...@@ -384,11 +384,11 @@ struct M ...@@ -384,11 +384,11 @@ struct M
// these are here because they are too large to be on the stack // these are here because they are too large to be on the stack
// of low-level NOSPLIT functions. // of low-level NOSPLIT functions.
LibCall libcall; LibCall libcall;
struct { struct MTs {
int64 tv_sec; int64 tv_sec;
int64 tv_nsec; int64 tv_nsec;
} ts; } ts;
struct { struct MScratch {
uintptr v[6]; uintptr v[6];
} scratch; } scratch;
#endif #endif
......
...@@ -52,7 +52,7 @@ typedef uint16 Elf64_Section; ...@@ -52,7 +52,7 @@ typedef uint16 Elf64_Section;
typedef Elf64_Half Elf64_Versym; typedef Elf64_Half Elf64_Versym;
typedef struct typedef struct Elf64_Sym
{ {
Elf64_Word st_name; Elf64_Word st_name;
byte st_info; byte st_info;
...@@ -62,7 +62,7 @@ typedef struct ...@@ -62,7 +62,7 @@ typedef struct
Elf64_Xword st_size; Elf64_Xword st_size;
} Elf64_Sym; } Elf64_Sym;
typedef struct typedef struct Elf64_Verdef
{ {
Elf64_Half vd_version; /* Version revision */ Elf64_Half vd_version; /* Version revision */
Elf64_Half vd_flags; /* Version information */ Elf64_Half vd_flags; /* Version information */
...@@ -73,7 +73,7 @@ typedef struct ...@@ -73,7 +73,7 @@ typedef struct
Elf64_Word vd_next; /* Offset in bytes to next verdef entry */ Elf64_Word vd_next; /* Offset in bytes to next verdef entry */
} Elf64_Verdef; } Elf64_Verdef;
typedef struct typedef struct Elf64_Ehdr
{ {
byte e_ident[EI_NIDENT]; /* Magic number and other info */ byte e_ident[EI_NIDENT]; /* Magic number and other info */
Elf64_Half e_type; /* Object file type */ Elf64_Half e_type; /* Object file type */
...@@ -91,7 +91,7 @@ typedef struct ...@@ -91,7 +91,7 @@ typedef struct
Elf64_Half e_shstrndx; /* Section header string table index */ Elf64_Half e_shstrndx; /* Section header string table index */
} Elf64_Ehdr; } Elf64_Ehdr;
typedef struct typedef struct Elf64_Phdr
{ {
Elf64_Word p_type; /* Segment type */ Elf64_Word p_type; /* Segment type */
Elf64_Word p_flags; /* Segment flags */ Elf64_Word p_flags; /* Segment flags */
...@@ -103,7 +103,7 @@ typedef struct ...@@ -103,7 +103,7 @@ typedef struct
Elf64_Xword p_align; /* Segment alignment */ Elf64_Xword p_align; /* Segment alignment */
} Elf64_Phdr; } Elf64_Phdr;
typedef struct typedef struct Elf64_Shdr
{ {
Elf64_Word sh_name; /* Section name (string tbl index) */ Elf64_Word sh_name; /* Section name (string tbl index) */
Elf64_Word sh_type; /* Section type */ Elf64_Word sh_type; /* Section type */
...@@ -117,7 +117,7 @@ typedef struct ...@@ -117,7 +117,7 @@ typedef struct
Elf64_Xword sh_entsize; /* Entry size if section holds table */ Elf64_Xword sh_entsize; /* Entry size if section holds table */
} Elf64_Shdr; } Elf64_Shdr;
typedef struct typedef struct Elf64_Dyn
{ {
Elf64_Sxword d_tag; /* Dynamic entry type */ Elf64_Sxword d_tag; /* Dynamic entry type */
union union
...@@ -127,13 +127,13 @@ typedef struct ...@@ -127,13 +127,13 @@ typedef struct
} d_un; } d_un;
} Elf64_Dyn; } Elf64_Dyn;
typedef struct typedef struct Elf64_Verdaux
{ {
Elf64_Word vda_name; /* Version or dependency names */ Elf64_Word vda_name; /* Version or dependency names */
Elf64_Word vda_next; /* Offset in bytes to next verdaux entry */ Elf64_Word vda_next; /* Offset in bytes to next verdaux entry */
} Elf64_Verdaux; } Elf64_Verdaux;
typedef struct typedef struct Elf64_auxv_t
{ {
uint64 a_type; /* Entry type */ uint64 a_type; /* Entry type */
union union
...@@ -143,13 +143,13 @@ typedef struct ...@@ -143,13 +143,13 @@ typedef struct
} Elf64_auxv_t; } Elf64_auxv_t;
typedef struct { typedef struct symbol_key {
byte* name; byte* name;
int32 sym_hash; int32 sym_hash;
void** var_ptr; void** var_ptr;
} symbol_key; } symbol_key;
typedef struct { typedef struct version_key {
byte* version; byte* version;
int32 ver_hash; int32 ver_hash;
} version_key; } version_key;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment