Fix for VS 2015 stricter warnings about "shadowed" names.

This change renames a few variables to fix the build in VS 2015.

VS 2015 new warnings:
http://blogs.msdn.com/b/vcblog/archive/2014/11/12/improvements-to-warnings-in-the-c-compiler.aspx

Change-Id: Ic9c3f75ee717f0125960c813df442ed4fbcceb4a
This commit is contained in:
Max Galkin 2015-03-07 08:49:55 -08:00 committed by Wouter van Oortmerssen
parent a360958be3
commit c3807fa39d
3 changed files with 29 additions and 29 deletions

View File

@ -112,18 +112,18 @@ int main(int argc, const char *argv[]) {
std::vector<std::string> filenames;
std::vector<const char *> include_directories;
size_t binary_files_from = std::numeric_limits<size_t>::max();
for (int i = 1; i < argc; i++) {
const char *arg = argv[i];
for (int argi = 1; argi < argc; argi++) {
const char *arg = argv[argi];
if (arg[0] == '-') {
if (filenames.size() && arg[1] != '-')
Error("invalid option location", arg, true);
std::string opt = arg;
if (opt == "-o") {
if (++i >= argc) Error("missing path following", arg, true);
output_path = flatbuffers::ConCatPathFileName(argv[i], "");
if (++argi >= argc) Error("missing path following", arg, true);
output_path = flatbuffers::ConCatPathFileName(argv[argi], "");
} else if(opt == "-I") {
if (++i >= argc) Error("missing path following", arg, true);
include_directories.push_back(argv[i]);
if (++argi >= argc) Error("missing path following", arg, true);
include_directories.push_back(argv[argi]);
} else if(opt == "--strict-json") {
opts.strict_json = true;
} else if(opt == "--no-prefix") {
@ -149,7 +149,7 @@ int main(int argc, const char *argv[]) {
found:;
}
} else {
filenames.push_back(argv[i]);
filenames.push_back(argv[argi]);
}
}

View File

@ -58,9 +58,9 @@ std::string GenerateFBS(const Parser &parser, const std::string &file_name,
}
schema += ";\n\n";
// Generate code for all the enum declarations.
for (auto it = parser.enums_.vec.begin();
it != parser.enums_.vec.end(); ++it) {
EnumDef &enum_def = **it;
for (auto enum_def_it = parser.enums_.vec.begin();
enum_def_it != parser.enums_.vec.end(); ++enum_def_it) {
EnumDef &enum_def = **enum_def_it;
schema += "enum " + enum_def.name + " : ";
schema += GenType(enum_def.underlying_type) + " {\n";
for (auto it = enum_def.vals.vec.begin();
@ -75,9 +75,9 @@ std::string GenerateFBS(const Parser &parser, const std::string &file_name,
it != parser.structs_.vec.end(); ++it) {
StructDef &struct_def = **it;
schema += "table " + struct_def.name + " {\n";
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
auto &field = **it;
for (auto field_it = struct_def.fields.vec.begin();
field_it != struct_def.fields.vec.end(); ++field_it) {
auto &field = **field_it;
schema += " " + field.name + ":" + GenType(field.value.type);
if (field.value.constant != "0") schema += " = " + field.value.constant;
if (field.required) schema += " (required)";

View File

@ -787,17 +787,17 @@ StructDef *Parser::LookupCreateStruct(const std::string &name) {
}
void Parser::ParseEnum(bool is_union) {
std::vector<std::string> dc = doc_comment_;
std::vector<std::string> enum_comment = doc_comment_;
Next();
std::string name = attribute_;
std::string enum_name = attribute_;
Expect(kTokenIdentifier);
auto &enum_def = *new EnumDef();
enum_def.name = name;
enum_def.name = enum_name;
if (!files_being_parsed_.empty()) enum_def.file = files_being_parsed_.top();
enum_def.doc_comment = dc;
enum_def.doc_comment = enum_comment;
enum_def.is_union = is_union;
enum_def.defined_namespace = namespaces_.back();
if (enums_.Add(name, &enum_def)) Error("enum already exists: " + name);
if (enums_.Add(enum_name, &enum_def)) Error("enum already exists: " + enum_name);
if (is_union) {
enum_def.underlying_type.base_type = BASE_TYPE_UTYPE;
enum_def.underlying_type.enum_def = &enum_def;
@ -821,19 +821,19 @@ void Parser::ParseEnum(bool is_union) {
Expect('{');
if (is_union) enum_def.vals.Add("NONE", new EnumVal("NONE", 0));
do {
std::string name = attribute_;
std::vector<std::string> dc = doc_comment_;
std::string value_name = attribute_;
std::vector<std::string> value_comment = doc_comment_;
Expect(kTokenIdentifier);
auto prevsize = enum_def.vals.vec.size();
auto value = enum_def.vals.vec.size()
? enum_def.vals.vec.back()->value + 1
: 0;
auto &ev = *new EnumVal(name, value);
if (enum_def.vals.Add(name, &ev))
Error("enum value already exists: " + name);
ev.doc_comment = dc;
auto &ev = *new EnumVal(value_name, value);
if (enum_def.vals.Add(value_name, &ev))
Error("enum value already exists: " + value_name);
ev.doc_comment = value_comment;
if (is_union) {
ev.struct_def = LookupCreateStruct(name);
ev.struct_def = LookupCreateStruct(value_name);
}
if (IsNext('=')) {
ev.value = atoi(attribute_.c_str());
@ -1198,10 +1198,10 @@ bool Parser::Parse(const char *source, const char **include_paths,
for (auto it = enums_.vec.begin(); it != enums_.vec.end(); ++it) {
auto &enum_def = **it;
if (enum_def.is_union) {
for (auto it = enum_def.vals.vec.begin();
it != enum_def.vals.vec.end();
++it) {
auto &val = **it;
for (auto val_it = enum_def.vals.vec.begin();
val_it != enum_def.vals.vec.end();
++val_it) {
auto &val = **val_it;
if (val.struct_def && val.struct_def->fixed)
Error("only tables can be union elements: " + val.name);
}