mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-21 09:20:12 +01:00
glsl: Fix missing initialization of yylloc.source
In both the preprocessor and in the compiler proper, we use a custom yyltype struct to allow tracking the source-string number in addition to line and column. However, we were previously relying on bison's default initialization of the yyltype struct which of course is not aware of the source field and leaves it uninitialized. We fix this by defining our own YYLLOC_DEFAULT macro expanding on the default version (as appears in the bison manual) and adding initialization of yylloc.source.
This commit is contained in:
parent
c24bcad9f8
commit
a0cfe8c440
2 changed files with 38 additions and 0 deletions
|
|
@ -69,6 +69,25 @@ typedef struct YYLTYPE {
|
||||||
# define YYLTYPE_IS_DECLARED 1
|
# define YYLTYPE_IS_DECLARED 1
|
||||||
# define YYLTYPE_IS_TRIVIAL 1
|
# define YYLTYPE_IS_TRIVIAL 1
|
||||||
|
|
||||||
|
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||||
|
do { \
|
||||||
|
if (N) \
|
||||||
|
{ \
|
||||||
|
(Current).first_line = YYRHSLOC(Rhs, 1).first_line; \
|
||||||
|
(Current).first_column = YYRHSLOC(Rhs, 1).first_column; \
|
||||||
|
(Current).last_line = YYRHSLOC(Rhs, N).last_line; \
|
||||||
|
(Current).last_column = YYRHSLOC(Rhs, N).last_column; \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
{ \
|
||||||
|
(Current).first_line = (Current).last_line = \
|
||||||
|
YYRHSLOC(Rhs, 0).last_line; \
|
||||||
|
(Current).first_column = (Current).last_column = \
|
||||||
|
YYRHSLOC(Rhs, 0).last_column; \
|
||||||
|
} \
|
||||||
|
(Current).source = 0; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
struct token {
|
struct token {
|
||||||
int type;
|
int type;
|
||||||
YYSTYPE value;
|
YYSTYPE value;
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,25 @@ typedef struct YYLTYPE {
|
||||||
# define YYLTYPE_IS_DECLARED 1
|
# define YYLTYPE_IS_DECLARED 1
|
||||||
# define YYLTYPE_IS_TRIVIAL 1
|
# define YYLTYPE_IS_TRIVIAL 1
|
||||||
|
|
||||||
|
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||||
|
do { \
|
||||||
|
if (N) \
|
||||||
|
{ \
|
||||||
|
(Current).first_line = YYRHSLOC(Rhs, 1).first_line; \
|
||||||
|
(Current).first_column = YYRHSLOC(Rhs, 1).first_column; \
|
||||||
|
(Current).last_line = YYRHSLOC(Rhs, N).last_line; \
|
||||||
|
(Current).last_column = YYRHSLOC(Rhs, N).last_column; \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
{ \
|
||||||
|
(Current).first_line = (Current).last_line = \
|
||||||
|
YYRHSLOC(Rhs, 0).last_line; \
|
||||||
|
(Current).first_column = (Current).last_column = \
|
||||||
|
YYRHSLOC(Rhs, 0).last_column; \
|
||||||
|
} \
|
||||||
|
(Current).source = 0; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
extern void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state,
|
extern void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state,
|
||||||
const char *fmt, ...);
|
const char *fmt, ...);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue