mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-22 06:38:09 +02:00
glsl: empty declarations should be valid
Unlike C++, empty declarations such as
float;
should be valid. The spec is not explicit about this actually.
Some apps that generate their shader sources may rely on this. This was
noted when porting one of them to Linux from Windows.
Reviewed-by: Chad Versace <chad@chad-versace.us>
Note: this is a candidate for the 7.11 branch.
(cherry picked from commit 547212d963)
This commit is contained in:
parent
ffb0f94136
commit
2cadae90c0
2 changed files with 8 additions and 12 deletions
|
|
@ -2391,12 +2391,12 @@ ast_declarator_list::hir(exec_list *instructions,
|
|||
|
||||
decl_type = this->type->specifier->glsl_type(& type_name, state);
|
||||
if (this->declarations.is_empty()) {
|
||||
/* The only valid case where the declaration list can be empty is when
|
||||
* the declaration is setting the default precision of a built-in type
|
||||
* (e.g., 'precision highp vec4;').
|
||||
*/
|
||||
|
||||
if (decl_type != NULL) {
|
||||
/* Warn if this empty declaration is not for declaring a structure.
|
||||
*/
|
||||
if (this->type->specifier->structure == NULL) {
|
||||
_mesa_glsl_warning(&loc, state, "empty declaration");
|
||||
}
|
||||
} else {
|
||||
_mesa_glsl_error(& loc, state, "incomplete declaration");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -971,13 +971,9 @@ single_declaration:
|
|||
fully_specified_type
|
||||
{
|
||||
void *ctx = state;
|
||||
if ($1->specifier->type_specifier != ast_struct) {
|
||||
_mesa_glsl_error(& @1, state, "empty declaration list\n");
|
||||
YYERROR;
|
||||
} else {
|
||||
$$ = new(ctx) ast_declarator_list($1);
|
||||
$$->set_location(yylloc);
|
||||
}
|
||||
/* Empty declaration list is valid. */
|
||||
$$ = new(ctx) ast_declarator_list($1);
|
||||
$$->set_location(yylloc);
|
||||
}
|
||||
| fully_specified_type any_identifier
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue