summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2013-07-15 15:06:31 -0700
committerKenneth Graunke <[email protected]>2013-07-18 16:57:22 -0700
commit293dfe5738019d0f8367e68f0b74e438482c9d82 (patch)
tree6e13a685398319bf31d897877b152880b5af0cc7
parenta4d15a3cd963dee6beb0b6d8a4c25b371ea9a289 (diff)
glsl: Handle "const" as a parameter qualifier.
This will make it easy to support both "const in" and "in const", as required by GLSL 4.20/ARB_shading_language_420pack. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
-rw-r--r--src/glsl/glsl_parser.yy43
1 files changed, 14 insertions, 29 deletions
diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 0c5defb47a7..1ce28e2e121 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -181,7 +181,6 @@ static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg)
%type <parameter_declarator> parameter_declaration
%type <type_qualifier> parameter_qualifier
%type <type_qualifier> parameter_direction_qualifier
-%type <type_qualifier> parameter_type_qualifier
%type <type_specifier> parameter_type_specifier
%type <function_definition> function_definition
%type <compound_statement> compound_statement_no_new_scope
@@ -865,29 +864,11 @@ parameter_declarator:
;
parameter_declaration:
- parameter_type_qualifier parameter_qualifier parameter_declarator
- {
- $1.flags.i |= $2.flags.i;
-
- $$ = $3;
- $$->type->qualifier = $1;
- }
- | parameter_qualifier parameter_declarator
+ parameter_qualifier parameter_declarator
{
$$ = $2;
$$->type->qualifier = $1;
}
- | parameter_type_qualifier parameter_qualifier parameter_type_specifier
- {
- void *ctx = state;
- $1.flags.i |= $2.flags.i;
-
- $$ = new(ctx) ast_parameter_declarator();
- $$->set_location(yylloc);
- $$->type = new(ctx) ast_fully_specified_type();
- $$->type->qualifier = $1;
- $$->type->specifier = $3;
- }
| parameter_qualifier parameter_type_specifier
{
void *ctx = state;
@@ -904,10 +885,22 @@ parameter_qualifier:
{
memset(& $$, 0, sizeof($$));
}
+ | CONST_TOK parameter_qualifier
+ {
+ if ($2.flags.q.constant)
+ _mesa_glsl_error(&@1, state, "duplicate const qualifier.\n");
+
+ $$ = $2;
+ $$.flags.q.constant = 1;
+ }
| parameter_direction_qualifier parameter_qualifier
{
if (($1.flags.q.in || $1.flags.q.out) && ($2.flags.q.in || $2.flags.q.out))
- _mesa_glsl_error(&@1, state, "duplicate in/out/inout qualifier");
+ _mesa_glsl_error(&@1, state, "duplicate in/out/inout qualifier\n");
+
+ if ($2.flags.q.constant)
+ _mesa_glsl_error(&@1, state, "const must be specified before "
+ "in/out/inout.\n");
$$ = $1;
$$.merge_qualifier(&@1, state, $2);
@@ -1316,14 +1309,6 @@ interpolation_qualifier:
}
;
-parameter_type_qualifier:
- CONST_TOK
- {
- memset(& $$, 0, sizeof($$));
- $$.flags.q.constant = 1;
- }
- ;
-
type_qualifier:
/* Single qualifiers */
INVARIANT