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:
}
| LSTRUCT sbody
{
diag(Z, "struct must have tag");
taggen++;
sprint(symb, "_%d_", taggen);
$$ = 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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
......@@ -15,7 +16,9 @@
GNU General Public License for more details.
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
part or all of the Bison parser skeleton and distribute that work
......@@ -30,16 +33,6 @@
This special exception was added by the Free Software Foundation in
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. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
......@@ -196,12 +189,11 @@ extern int yydebug;
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 2053 of yacc.c */
#line 36 "cc.y"
{
Node* node;
Sym* sym;
Type* type;
......@@ -225,30 +217,14 @@ typedef union YYSTYPE
int32 lval;
double dval;
vlong vval;
/* Line 2053 of yacc.c */
#line 232 "y.tab.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
}
/* Line 1529 of yacc.c. */
#line 223 "y.tab.h"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
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
bool debuggc;
// Statistics about allocation size classes.
struct {
struct MStatsBySize {
uint32 size;
uint64 nmalloc;
uint64 nfree;
......@@ -282,6 +283,7 @@ struct MStats
uint64 tinyallocs; // number of tiny allocations that didn't cause actual allocation; not exported to Go directly
};
#define mstats runtime·memstats
extern MStats mstats;
void runtime·updatememstats(GCStats *stats);
......@@ -489,7 +491,7 @@ struct MHeap
// the padding makes sure that the MCentrals are
// spaced CacheLineSize bytes apart, so that each MCentral.lock
// gets its own cache line.
struct {
struct MHeapCentral {
MCentral mcentral;
byte pad[CacheLineSize];
} central[NumSizeClasses];
......
......@@ -63,7 +63,7 @@ typedef struct Tos Tos;
typedef intptr _Plink;
struct Tos {
struct /* Per process profiling */
struct TosProf /* Per process profiling */
{
_Plink *pp; /* known to be 0(ptr) */
_Plink *next; /* known to be 4(ptr) */
......
......@@ -2421,7 +2421,7 @@ runtime·mcount(void)
return runtime·sched.mcount;
}
static struct {
static struct ProfState {
uint32 lock;
int32 hz;
} prof;
......
......@@ -384,11 +384,11 @@ struct M
// these are here because they are too large to be on the stack
// of low-level NOSPLIT functions.
LibCall libcall;
struct {
struct MTs {
int64 tv_sec;
int64 tv_nsec;
} ts;
struct {
struct MScratch {
uintptr v[6];
} scratch;
#endif
......
......@@ -52,7 +52,7 @@ typedef uint16 Elf64_Section;
typedef Elf64_Half Elf64_Versym;
typedef struct
typedef struct Elf64_Sym
{
Elf64_Word st_name;
byte st_info;
......@@ -62,7 +62,7 @@ typedef struct
Elf64_Xword st_size;
} Elf64_Sym;
typedef struct
typedef struct Elf64_Verdef
{
Elf64_Half vd_version; /* Version revision */
Elf64_Half vd_flags; /* Version information */
......@@ -73,7 +73,7 @@ typedef struct
Elf64_Word vd_next; /* Offset in bytes to next verdef entry */
} Elf64_Verdef;
typedef struct
typedef struct Elf64_Ehdr
{
byte e_ident[EI_NIDENT]; /* Magic number and other info */
Elf64_Half e_type; /* Object file type */
......@@ -91,7 +91,7 @@ typedef struct
Elf64_Half e_shstrndx; /* Section header string table index */
} Elf64_Ehdr;
typedef struct
typedef struct Elf64_Phdr
{
Elf64_Word p_type; /* Segment type */
Elf64_Word p_flags; /* Segment flags */
......@@ -103,7 +103,7 @@ typedef struct
Elf64_Xword p_align; /* Segment alignment */
} Elf64_Phdr;
typedef struct
typedef struct Elf64_Shdr
{
Elf64_Word sh_name; /* Section name (string tbl index) */
Elf64_Word sh_type; /* Section type */
......@@ -117,7 +117,7 @@ typedef struct
Elf64_Xword sh_entsize; /* Entry size if section holds table */
} Elf64_Shdr;
typedef struct
typedef struct Elf64_Dyn
{
Elf64_Sxword d_tag; /* Dynamic entry type */
union
......@@ -127,13 +127,13 @@ typedef struct
} d_un;
} Elf64_Dyn;
typedef struct
typedef struct Elf64_Verdaux
{
Elf64_Word vda_name; /* Version or dependency names */
Elf64_Word vda_next; /* Offset in bytes to next verdaux entry */
} Elf64_Verdaux;
typedef struct
typedef struct Elf64_auxv_t
{
uint64 a_type; /* Entry type */
union
......@@ -143,13 +143,13 @@ typedef struct
} Elf64_auxv_t;
typedef struct {
typedef struct symbol_key {
byte* name;
int32 sym_hash;
void** var_ptr;
} symbol_key;
typedef struct {
typedef struct version_key {
byte* version;
int32 ver_hash;
} 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