glapi: Fix -Wduplicate-decl-specifier due to double-const
authorChad Versace <chadversary@chromium.org>
Thu, 22 Jun 2017 22:12:29 +0000 (15:12 -0700)
committerChad Versace <chadversary@chromium.org>
Mon, 26 Jun 2017 17:26:23 +0000 (10:26 -0700)
Fix all lines in src/mesa/main/marshal_generated.c that declare
double-const variables. Below is all such lines, with duplicates
removed:

   $ grep 'const const' marshal_generated.c | sort -u
   const const GLboolean * pointer = cmd->pointer;
   const const GLvoid * indices = cmd->indices;
   const const GLvoid * pointer = cmd->pointer;

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mapi/glapi/gen/gl_marshal.py

index 062afe566fd44cbd0b63b61bb5faec57003fe040..efa4d9e6f90d3f8cb0cc8db1d54066da57277e9b 100644 (file)
@@ -173,11 +173,19 @@ class PrintCode(gl_XML.gl_print_base):
         with indent():
             for p in func.fixed_params:
                 if p.count:
-                    out('const {0} * {1} = cmd->{1};'.format(
-                            p.get_base_type_string(), p.name))
+                    p_decl = '{0} * {1} = cmd->{1};'.format(
+                            p.get_base_type_string(), p.name)
                 else:
-                    out('const {0} {1} = cmd->{1};'.format(
-                            p.type_string(), p.name))
+                    p_decl = '{0} {1} = cmd->{1};'.format(
+                            p.type_string(), p.name)
+
+                if not p_decl.startswith('const '):
+                    # Declare all local function variables as const, even if
+                    # the original parameter is not const.
+                    p_decl = 'const ' + p_decl
+
+                out(p_decl)
+
             if func.variable_params:
                 for p in func.variable_params:
                     out('const {0} * {1};'.format(