glsl: Clear type_qualifier using memset
[mesa.git] / src / glsl / glsl_parser.ypp
index 9d311093ba619ff2417316930caa17445ffd14d1..be763ed9f03eb551139ec873b9a19f80cd9e517d 100644 (file)
@@ -793,10 +793,25 @@ parameter_declaration:
        ;
 
 parameter_qualifier:
-       /* empty */     { $$.i = 0; }
-       | IN_TOK        { $$.i = 0; $$.q.in = 1; }
-       | OUT_TOK       { $$.i = 0; $$.q.out = 1; }
-       | INOUT_TOK     { $$.i = 0; $$.q.in = 1; $$.q.out = 1; }
+       /* empty */
+       {
+          memset(& $$, 0, sizeof($$));
+       }
+       | IN_TOK
+       {
+          memset(& $$, 0, sizeof($$));
+          $$.q.in = 1;
+       }
+       | OUT_TOK
+       {
+          memset(& $$, 0, sizeof($$));
+          $$.q.out = 1;
+       }
+       | INOUT_TOK
+       {
+          memset(& $$, 0, sizeof($$));
+          $$.q.in = 1; $$.q.out = 1;
+       }
        ;
 
 parameter_type_specifier:
@@ -977,11 +992,11 @@ layout_qualifier_id_list:
 layout_qualifier_id:
        IDENTIFIER
        {
-          $$.i = 0;
+          bool got_one = false;
 
-          if (state->ARB_fragment_coord_conventions_enable) {
-             bool got_one = false;
+          memset(& $$, 0, sizeof($$));
 
+          if (state->ARB_fragment_coord_conventions_enable) {
              if (strcmp($1, "origin_upper_left") == 0) {
                 got_one = true;
                 $$.q.origin_upper_left = 1;
@@ -989,33 +1004,47 @@ layout_qualifier_id:
                 got_one = true;
                 $$.q.pixel_center_integer = 1;
              }
-
-             if (state->ARB_fragment_coord_conventions_warn && got_one) {
-                _mesa_glsl_warning(& @1, state,
-                                   "GL_ARB_fragment_coord_conventions layout "
-                                   "identifier `%s' used\n", $1);
-             }
           }
 
           /* If the identifier didn't match any known layout identifiers,
            * emit an error.
            */
-          if ($$.i == 0) {
+          if (!got_one) {
              _mesa_glsl_error(& @1, state, "unrecognized layout identifier "
                               "`%s'\n", $1);
              YYERROR;
+          } else if (state->ARB_fragment_coord_conventions_warn) {
+             _mesa_glsl_warning(& @1, state,
+                                "GL_ARB_fragment_coord_conventions layout "
+                                "identifier `%s' used\n", $1);
           }
        }
        ;
 
 interpolation_qualifier:
-       SMOOTH          { $$.i = 0; $$.q.smooth = 1; }
-       | FLAT          { $$.i = 0; $$.q.flat = 1; }
-       | NOPERSPECTIVE { $$.i = 0; $$.q.noperspective = 1; }
+       SMOOTH
+       {
+          memset(& $$, 0, sizeof($$));
+          $$.q.smooth = 1;
+       }
+       | FLAT
+       {
+          memset(& $$, 0, sizeof($$));
+          $$.q.flat = 1;
+       }
+       | NOPERSPECTIVE
+       {
+          memset(& $$, 0, sizeof($$));
+          $$.q.noperspective = 1;
+       }
        ;
 
 parameter_type_qualifier:
-       CONST_TOK       { $$.i = 0; $$.q.constant = 1; }
+       CONST_TOK
+       {
+          memset(& $$, 0, sizeof($$));
+          $$.q.constant = 1;
+       }
        ;
 
 type_qualifier:
@@ -1042,21 +1071,57 @@ type_qualifier:
        }
        | INVARIANT
        {
-          $$.i = 0;
+          memset(& $$, 0, sizeof($$));
           $$.q.invariant = 1;
        }
        ;
 
 storage_qualifier:
-       CONST_TOK               { $$.i = 0; $$.q.constant = 1; }
-       | ATTRIBUTE             { $$.i = 0; $$.q.attribute = 1; }
-       | VARYING               { $$.i = 0; $$.q.varying = 1; }
-       | CENTROID VARYING      { $$.i = 0; $$.q.centroid = 1; $$.q.varying = 1; }
-       | IN_TOK                { $$.i = 0; $$.q.in = 1; }
-       | OUT_TOK               { $$.i = 0; $$.q.out = 1; }
-       | CENTROID IN_TOK       { $$.i = 0; $$.q.centroid = 1; $$.q.in = 1; }
-       | CENTROID OUT_TOK      { $$.i = 0; $$.q.centroid = 1; $$.q.out = 1; }
-       | UNIFORM               { $$.i = 0; $$.q.uniform = 1; }
+       CONST_TOK
+       {
+          memset(& $$, 0, sizeof($$));
+          $$.q.constant = 1;
+       }
+       | ATTRIBUTE
+       {
+          memset(& $$, 0, sizeof($$));
+          $$.q.attribute = 1;
+       }
+       | VARYING
+       {
+          memset(& $$, 0, sizeof($$));
+          $$.q.varying = 1;
+       }
+       | CENTROID VARYING
+       {
+          memset(& $$, 0, sizeof($$));
+          $$.q.centroid = 1; $$.q.varying = 1;
+       }
+       | IN_TOK
+       {
+          memset(& $$, 0, sizeof($$));
+          $$.q.in = 1;
+       }
+       | OUT_TOK
+       {
+          memset(& $$, 0, sizeof($$));
+          $$.q.out = 1;
+       }
+       | CENTROID IN_TOK
+       {
+          memset(& $$, 0, sizeof($$));
+          $$.q.centroid = 1; $$.q.in = 1;
+       }
+       | CENTROID OUT_TOK
+       {
+          memset(& $$, 0, sizeof($$));
+          $$.q.centroid = 1; $$.q.out = 1;
+       }
+       | UNIFORM
+       {
+          memset(& $$, 0, sizeof($$));
+          $$.q.uniform = 1;
+       }
        ;
 
 type_specifier: