generator is generating following code: const const GLvoid * pointer = cmd->pointer; that results later as compilation warning: --- 8< --- marshal_generated.c:15836:10: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier] const const GLvoid * pointer = cmd->pointer; --- 8< --- I've tried to fix this by inserting const decl specifier only if p.string() does not already start with 'const' but this will create new compilation warnings like: --- 8< --- main/marshal_generated.c:29774:18: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] GLbyte * v = cmd->v; --- 8< --- I'm filing this so that some Python guru can take a look at it.
Created attachment 130255 [details] [review] attempt to fix warnings this was my 1st attempt to fix this
I didn't really looked at the python generator, but this is what came to my mind: maybe one of the consts was meant to be applied to the pointee type? So instead of "const const GLvoid *", it should be "const GLvoid *const"?
I agree with Gustaw, that it should be changed to "const GLvoid *const". Something like that should work(not tested): --- a/src/mapi/glapi/gen/gl_marshal.py +++ b/src/mapi/glapi/gen/gl_marshal.py @@ -177,11 +177,11 @@ 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)) + out('const {0} * const {1} = cmd->{1};'.format( + p.get_base_type_string().lstrip('const'), p.name)) else: out('const {0} {1} = cmd->{1};'.format( - p.type_string(), p.name)) + p.type_string().lstrip('const'), p.name)) if func.variable_params: for p in func.variable_params: out('const {0} * {1};'.format(
Gustaw, you're right. Can you prepare a patch that moves the const in the right place? Bartosz, the lstrip() should not be required.
Fixed by: commit 31c3c440b5361299fc0529bcf049e9b271d4fab9 Author: Chad Versace <chadversary@chromium.org> Date: Thu Jun 22 15:12:29 2017 -0700 glapi: Fix -Wduplicate-decl-specifier due to double-const 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>
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.