diff options
author | Michi Henning <michi@zeroc.com> | 2002-07-01 06:02:00 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2002-07-01 06:02:00 +0000 |
commit | feb966f1dd8b46d87c550260c40242db70849a34 (patch) | |
tree | d85854a28bc67fb6a66815f4eed10bc9875a0709 /cpp/src/Slice/Parser.cpp | |
parent | Added case-insensitive checks for ambiguous multiple inheritance. CICompare (diff) | |
download | ice-feb966f1dd8b46d87c550260c40242db70849a34.tar.bz2 ice-feb966f1dd8b46d87c550260c40242db70849a34.tar.xz ice-feb966f1dd8b46d87c550260c40242db70849a34.zip |
Added additional check to make sure that no exception is mentioned more
than once in a throws clause. Fixed a bug in the exception checking
code: ::e and e were mistaken as differing only in case in a throws
clause. Style fixes.
Diffstat (limited to 'cpp/src/Slice/Parser.cpp')
-rw-r--r-- | cpp/src/Slice/Parser.cpp | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index da052a6aa36..a4741fd589b 100644 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -898,7 +898,16 @@ Slice::Container::lookupException(const string& scoped, bool printError) } return 0; } - if(printError && (*p)->name() != scoped) + string sc; + if(scoped.size() >= 2 && scoped[0] == ':') + { + sc = scoped.substr(2); + } + else + { + sc = scoped; + } + if(printError && (*p)->name() != sc) { string msg; msg = "exception name `" + scoped + "' is capitalized inconsistently with its previous name: `"; @@ -1369,7 +1378,7 @@ Slice::Container::checkPairIntersections(const StringPartitionList& l, const str { for(StringList::const_iterator s1 = i->begin(); s1 != i->end(); ++s1) { - for (StringList::const_iterator s2 = j->begin(); s2 != j->end(); ++s2) + for(StringList::const_iterator s2 = j->begin(); s2 != j->end(); ++s2) { if((*s1) == (*s2) && reported.find(*s1) == reported.end()) { @@ -1681,8 +1690,44 @@ Slice::ClassDef::createOperation(const string& name, } } } + + // + // Check that no exception occurs more than once in the throws clause + // + ExceptionList uniqueExceptions = throws; + uniqueExceptions.sort(); + uniqueExceptions.unique(); + if(uniqueExceptions.size() != throws.size()) + { + // + // At least one exception appears twice + // + ExceptionList tmp = throws; + tmp.sort(); + ExceptionList duplicates; + set_difference(tmp.begin(), tmp.end(), + uniqueExceptions.begin(), uniqueExceptions.end(), + back_inserter(duplicates)); + string msg = "operation `" + name + "' has a throws clause with "; + if(duplicates.size() == 1) + { + msg += "a "; + } + msg += "duplicate exception"; + if(duplicates.size() > 1) + { + msg += "s"; + } + ExceptionList::const_iterator i = duplicates.begin(); + msg += ": `" + (*i)->name() + "'"; + for(i = ++i; i != duplicates.end(); ++i) + { + msg += ", `" + (*i)->name() + "'"; + } + _unit->error(msg); + } - OperationPtr op = new Operation(this, name, returnType, inParams, outParams, throws); + OperationPtr op = new Operation(this, name, returnType, inParams, outParams, uniqueExceptions); _contents.push_back(op); return op; } |