mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
[Universal parser] Fix -Wsuggest-attribute=format warnings
Under a configuration including `cppflags=-DUNIVERSAL_PARSER`, warnings listed below show in build time: ``` node.c:396:30: warning: initialization left-hand side might be a candidate for a format attribute [-Wsuggest-attribute=format] 396 | bug_report_func rb_bug = ast->node_buffer->config->bug; | ^~~ ``` ``` ruby_parser.c:655:21: warning: initialization left-hand side might be a candidate for a format attribute [-Wsuggest-attribute=format] 655 | .compile_warn = rb_compile_warn, | ^~~~~~~~~~~~~~~ ruby_parser.c:656:24: warning: initialization left-hand side might be a candidate for a format attribute [-Wsuggest-attribute=format] 656 | .compile_warning = rb_compile_warning, | ^~~~~~~~~~~~~~~~~~ ruby_parser.c:657:12: warning: initialization left-hand side might be a candidate for a format attribute [-Wsuggest-attribute=format] 657 | .bug = rb_bug, | ^~~~~~ ruby_parser.c:658:14: warning: initialization left-hand side might be a candidate for a format attribute [-Wsuggest-attribute=format] 658 | .fatal = rb_fatal, | ^~~~~~~~ ``` To fix, this patch suggests adding `__attribute__((format(printf, n, m)))` to those function declarations.
This commit is contained in:
parent
1d91a1ad2d
commit
40ecad0ad7
2 changed files with 17 additions and 6 deletions
3
node.h
3
node.h
|
@ -15,8 +15,7 @@
|
|||
#include "rubyparser.h"
|
||||
#include "ruby/backward/2/attributes.h"
|
||||
|
||||
typedef void (*bug_report_func)(const char *fmt, ...);
|
||||
|
||||
typedef void (*bug_report_func)(const char *fmt, ...) RUBYPARSER_ATTRIBUTE_FORMAT(1, 2);
|
||||
typedef struct node_buffer_elem_struct {
|
||||
struct node_buffer_elem_struct *next;
|
||||
long len; /* Length of nodes */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue