diff options
author | Mark Spruiell <mes@zeroc.com> | 2012-12-18 15:41:30 -0800 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2012-12-18 15:41:30 -0800 |
commit | cc4bb57723200a3148dfa8964e2f95109497c144 (patch) | |
tree | f856af1053fd3eb3a8ad9cd41675cce9947cda45 /cpp/src/Slice/Parser.cpp | |
parent | Demo & test script fixes for CPP_COMPILER detection (diff) | |
download | ice-cc4bb57723200a3148dfa8964e2f95109497c144.tar.bz2 ice-cc4bb57723200a3148dfa8964e2f95109497c144.tar.xz ice-cc4bb57723200a3148dfa8964e2f95109497c144.zip |
ICE-5148 - Slice parser bugs for optional values
Diffstat (limited to 'cpp/src/Slice/Parser.cpp')
-rw-r--r-- | cpp/src/Slice/Parser.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index a5e9ae958f8..16a06384e10 100644 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -3269,7 +3269,7 @@ Slice::ClassDef::createDataMember(const string& name, const TypePtr& type, bool // // Validate the tag. // - DataMemberList dml = allDataMembers(); + DataMemberList dml = dataMembers(); for(DataMemberList::iterator q = dml.begin(); q != dml.end(); ++q) { if((*q)->optional() && tag == (*q)->tag()) @@ -3804,7 +3804,7 @@ Slice::Exception::createDataMember(const string& name, const TypePtr& type, bool // // Validate the tag. // - DataMemberList dml = allDataMembers(); + DataMemberList dml = dataMembers(); for(DataMemberList::iterator q = dml.begin(); q != dml.end(); ++q) { if((*q)->optional() && tag == (*q)->tag()) @@ -5015,6 +5015,30 @@ Slice::Operation::createParamDecl(const string& name, const TypePtr& type, bool _unit->error(msg); } + if(optional) + { + // + // Check for a duplicate tag. + // + const string msg = "tag for optional parameter `" + name + "' is already in use"; + if(_returnIsOptional && tag == _returnTag) + { + _unit->error(msg); + } + else + { + ParamDeclList params = parameters(); + for(ParamDeclList::const_iterator p = params.begin(); p != params.end(); ++p) + { + if((*p)->optional() && (*p)->tag() == tag) + { + _unit->error(msg); + break; + } + } + } + } + ParamDeclPtr p = new ParamDecl(this, name, type, isOutParam, optional, tag); _contents.push_back(p); return p; |