diff options
author | Mark Spruiell <mes@zeroc.com> | 2010-07-19 13:44:26 -0700 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2010-07-19 13:44:26 -0700 |
commit | e3338e0521c071b7400797d793e9841a7c18914a (patch) | |
tree | 17d2b9153d66baaa8aa802d0347d1508ecca05bb /cpp/src/Slice/Parser.cpp | |
parent | removing references to SLICE2XSD (diff) | |
download | ice-e3338e0521c071b7400797d793e9841a7c18914a.tar.bz2 ice-e3338e0521c071b7400797d793e9841a7c18914a.tar.xz ice-e3338e0521c071b7400797d793e9841a7c18914a.zip |
bug 4771 - duplicate errors for underscores in identifiers
Diffstat (limited to 'cpp/src/Slice/Parser.cpp')
-rwxr-xr-x | cpp/src/Slice/Parser.cpp | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index 5711c7b77b1..b4269abccf4 100755 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -2142,34 +2142,32 @@ Slice::Container::checkIdentifier(const string& name) const { _unit->error("illegal trailing underscore in identifier `" + name + "'"); } - else if(name.rfind("__") != string::npos) + else if(name.find("__") != string::npos) { _unit->error("illegal double underscore in identifier `" + name + "'"); } - - if(_unit->currentIncludeLevel() == 0) + else if(_unit->currentIncludeLevel() == 0 && !_unit->allowUnderscore() && name.find('_') != string::npos) { // // For rules controlled by a translator option, we don't complain about included files. // + _unit->error("illegal underscore in identifier `" + name + "'"); + } - if(!_unit->allowUnderscore() && name.find('_') != string::npos) - { - _unit->error("illegal underscore in identifier `" + name + "'"); - } - - if(!_unit->allowIcePrefix()) + if(_unit->currentIncludeLevel() == 0 && !_unit->allowIcePrefix()) + { + // + // For rules controlled by a translator option, we don't complain about included files. + // + if(name.size() >= 3) { - if(name.size() >= 3) + string prefix3; + prefix3 += ::tolower(static_cast<unsigned char>(name[0])); + prefix3 += ::tolower(static_cast<unsigned char>(name[1])); + prefix3 += ::tolower(static_cast<unsigned char>(name[2])); + if(prefix3 == "ice") { - string prefix3; - prefix3 += ::tolower(static_cast<unsigned char>(name[0])); - prefix3 += ::tolower(static_cast<unsigned char>(name[1])); - prefix3 += ::tolower(static_cast<unsigned char>(name[2])); - if(prefix3 == "ice") - { - _unit->error("illegal identifier `" + name + "': `" + name.substr(0, 3) + "' prefix is reserved"); - } + _unit->error("illegal identifier `" + name + "': `" + name.substr(0, 3) + "' prefix is reserved"); } } } |