Commit 79a7f181 authored by KOBAYASHI Shuji's avatar KOBAYASHI Shuji

Avoid potential zero size array declaration; fix #4382

parent 4e45e320
...@@ -33,7 +33,6 @@ struct RArray { ...@@ -33,7 +33,6 @@ struct RArray {
} aux; } aux;
mrb_value *ptr; mrb_value *ptr;
} heap; } heap;
mrb_value embed[MRB_ARY_EMBED_LEN_MAX];
} as; } as;
}; };
...@@ -46,7 +45,7 @@ struct RArray { ...@@ -46,7 +45,7 @@ struct RArray {
#define ARY_UNSET_EMBED_FLAG(a) ((a)->flags &= ~(MRB_ARY_EMBED_MASK)) #define ARY_UNSET_EMBED_FLAG(a) ((a)->flags &= ~(MRB_ARY_EMBED_MASK))
#define ARY_EMBED_LEN(a) ((mrb_int)(((a)->flags & MRB_ARY_EMBED_MASK) - 1)) #define ARY_EMBED_LEN(a) ((mrb_int)(((a)->flags & MRB_ARY_EMBED_MASK) - 1))
#define ARY_SET_EMBED_LEN(a,len) ((a)->flags = ((a)->flags&~MRB_ARY_EMBED_MASK) | ((uint32_t)(len) + 1)) #define ARY_SET_EMBED_LEN(a,len) ((a)->flags = ((a)->flags&~MRB_ARY_EMBED_MASK) | ((uint32_t)(len) + 1))
#define ARY_EMBED_PTR(a) (&((a)->as.embed[0])) #define ARY_EMBED_PTR(a) ((mrb_value*)&(a)->as)
#define ARY_LEN(a) (ARY_EMBED_P(a)?ARY_EMBED_LEN(a):(a)->as.heap.len) #define ARY_LEN(a) (ARY_EMBED_P(a)?ARY_EMBED_LEN(a):(a)->as.heap.len)
#define ARY_PTR(a) (ARY_EMBED_P(a)?ARY_EMBED_PTR(a):(a)->as.heap.ptr) #define ARY_PTR(a) (ARY_EMBED_P(a)?ARY_EMBED_PTR(a):(a)->as.heap.ptr)
......
...@@ -3,7 +3,9 @@ MRuby::Toolchain.new(:clang) do |conf, _params| ...@@ -3,7 +3,9 @@ MRuby::Toolchain.new(:clang) do |conf, _params|
[conf.cc, conf.objc, conf.asm].each do |cc| [conf.cc, conf.objc, conf.asm].each do |cc|
cc.command = ENV['CC'] || 'clang' cc.command = ENV['CC'] || 'clang'
cc.flags << '-Wzero-length-array' unless ENV['CFLAGS']
end end
conf.cxx.command = ENV['CXX'] || 'clang++' conf.cxx.command = ENV['CXX'] || 'clang++'
conf.cxx.flags << '-Wzero-length-array' unless ENV['CXXFLAGS'] || ENV['CFLAGS']
conf.linker.command = ENV['LD'] || ENV['CXX'] || ENV['CC'] || 'clang' conf.linker.command = ENV['LD'] || ENV['CXX'] || ENV['CC'] || 'clang'
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment