diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2015-07-22 15:24:04 -0230 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2015-07-22 15:24:04 -0230 |
commit | 18aa4f55fa26e3908dfb8ff99fc68d4db9fd3c9d (patch) | |
tree | aa2f54ad8b8ac244186509cb798eb728ba4d4a23 /cpp | |
parent | Removed x64 platform notes (diff) | |
download | ice-18aa4f55fa26e3908dfb8ff99fc68d4db9fd3c9d.tar.bz2 ice-18aa4f55fa26e3908dfb8ff99fc68d4db9fd3c9d.tar.xz ice-18aa4f55fa26e3908dfb8ff99fc68d4db9fd3c9d.zip |
ICE-6645 Fixed issue in Slice compilers with param/member names hiding type definitions
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/src/Slice/Parser.cpp | 44 | ||||
-rw-r--r-- | cpp/test/Slice/errorDetection/ChangedMeaning.err | 49 | ||||
-rw-r--r-- | cpp/test/Slice/errorDetection/ChangedMeaning.ice | 3 |
3 files changed, 63 insertions, 33 deletions
diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index 36cefc9d750..fdfbffba453 100644 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -1178,6 +1178,14 @@ Slice::Container::lookupType(const string& scoped, bool printError) return lookupTypeNoBuiltin(scoped, printError); } +// +// TODO: Hack to keep binary compatibility with Ice 3.6.0, fix properly in Ice 3.7 +// +namespace +{ +bool ignoreUndefined = false; +} + TypeList Slice::Container::lookupTypeNoBuiltin(const string& scoped, bool printError) { @@ -1200,6 +1208,8 @@ Slice::Container::lookupTypeNoBuiltin(const string& scoped, bool printError) } TypeList results; + bool typeError = false; + vector<string> errors; if(sc.rfind('*') == sc.length() - 1) { // @@ -1256,10 +1266,9 @@ Slice::Container::lookupTypeNoBuiltin(const string& scoped, bool printError) string msg = (*p)->kindOf() + " name `" + scoped; msg += "' is capitalized inconsistently with its previous name: `"; msg += matches.front()->scoped() + "'"; - _unit->error(msg); + errors.push_back(msg); } - ExceptionPtr ex = ExceptionPtr::dynamicCast(*p); if(ex) { @@ -1276,14 +1285,15 @@ Slice::Container::lookupTypeNoBuiltin(const string& scoped, bool printError) TypePtr type = TypePtr::dynamicCast(*p); if(!type) { + typeError = true; if(printError) { string msg = "`"; msg += sc; msg += "' is not a type"; - _unit->error(msg); + errors.push_back(msg); } - return TypeList(); + break; // Possible that correct match is higher in scope } results.push_back(type); } @@ -1292,9 +1302,18 @@ Slice::Container::lookupTypeNoBuiltin(const string& scoped, bool printError) if(results.empty()) { ContainedPtr contained = ContainedPtr::dynamicCast(this); - if(!contained) + if(contained) { - if(printError) + if (typeError) + { + ignoreUndefined = true; + } + results = contained->container()->lookupTypeNoBuiltin(sc, printError); + ignoreUndefined = false; + } + else if(!typeError) + { + if(printError && !ignoreUndefined) { string msg = "`"; msg += sc; @@ -1303,10 +1322,21 @@ Slice::Container::lookupTypeNoBuiltin(const string& scoped, bool printError) } return TypeList(); } - return contained->container()->lookupTypeNoBuiltin(sc, printError); + if(typeError && results.empty() && printError) + { + for(vector<string>::const_iterator p = errors.begin(); p != errors.end(); ++p) + { + _unit->error(*p); + } + } + return results; } else { + for(vector<string>::const_iterator p = errors.begin(); p != errors.end(); ++p) + { + _unit->error(*p); + } return results; } } diff --git a/cpp/test/Slice/errorDetection/ChangedMeaning.err b/cpp/test/Slice/errorDetection/ChangedMeaning.err index 81955b472b3..8518ae0cc7f 100644 --- a/cpp/test/Slice/errorDetection/ChangedMeaning.err +++ b/cpp/test/Slice/errorDetection/ChangedMeaning.err @@ -1,25 +1,24 @@ -ChangedMeaning.ice:49: `M' has changed meaning -ChangedMeaning.ice:55: `M' has changed meaning -ChangedMeaning.ice:62: `i1' has changed meaning -ChangedMeaning.ice:63: `i2' has changed meaning -ChangedMeaning.ice:84: `e1' has changed meaning -ChangedMeaning.ice:85: `e2' has changed meaning -ChangedMeaning.ice:97: `c1' has changed meaning -ChangedMeaning.ice:98: `c2' has changed meaning -ChangedMeaning.ice:109: `blue' has changed meaning -ChangedMeaning.ice:119: `CounterSeq' has changed meaning -ChangedMeaning.ice:127: `counter' is not a type -ChangedMeaning.ice:128: redefinition of parameter `param' -ChangedMeaning.ice:146: `E' is not an exception -ChangedMeaning.ice:146: `E' has changed meaning -ChangedMeaning.ice:153: `E' has changed meaning -ChangedMeaning.ice:159: `E' has changed meaning -ChangedMeaning.ice:194: data member `X' differs only in capitalization from data member `x' -ChangedMeaning.ice:194: `X' has changed meaning -ChangedMeaning.ice:200: member `X' differs only in capitalization from member `x' -ChangedMeaning.ice:200: `X' has changed meaning -ChangedMeaning.ice:205: parameter `A' differs only in capitalization from parameter `a' -ChangedMeaning.ice:205: `A' has changed meaning -ChangedMeaning.ice:213: redefinition of operation `x' as data member `x' -ChangedMeaning.ice:225: exception member `X' differs only in capitalization from exception member `x' -ChangedMeaning.ice:225: `X' has changed meaning
\ No newline at end of file +ChangedMeaning.ice:50: `M' has changed meaning +ChangedMeaning.ice:56: `M' has changed meaning +ChangedMeaning.ice:63: `i1' has changed meaning +ChangedMeaning.ice:64: `i2' has changed meaning +ChangedMeaning.ice:85: `e1' has changed meaning +ChangedMeaning.ice:86: `e2' has changed meaning +ChangedMeaning.ice:98: `c1' has changed meaning +ChangedMeaning.ice:99: `c2' has changed meaning +ChangedMeaning.ice:110: `blue' has changed meaning +ChangedMeaning.ice:120: `CounterSeq' has changed meaning +ChangedMeaning.ice:129: redefinition of parameter `param' +ChangedMeaning.ice:147: `E' is not an exception +ChangedMeaning.ice:147: `E' has changed meaning +ChangedMeaning.ice:154: `E' has changed meaning +ChangedMeaning.ice:160: `E' has changed meaning +ChangedMeaning.ice:195: data member `X' differs only in capitalization from data member `x' +ChangedMeaning.ice:195: `X' has changed meaning +ChangedMeaning.ice:201: member `X' differs only in capitalization from member `x' +ChangedMeaning.ice:201: `X' has changed meaning +ChangedMeaning.ice:206: parameter `A' differs only in capitalization from parameter `a' +ChangedMeaning.ice:206: `A' has changed meaning +ChangedMeaning.ice:214: redefinition of operation `x' as data member `x' +ChangedMeaning.ice:226: exception member `X' differs only in capitalization from exception member `x' +ChangedMeaning.ice:226: `X' has changed meaning diff --git a/cpp/test/Slice/errorDetection/ChangedMeaning.ice b/cpp/test/Slice/errorDetection/ChangedMeaning.ice index 03e01af4cc7..5c4005246c0 100644 --- a/cpp/test/Slice/errorDetection/ChangedMeaning.ice +++ b/cpp/test/Slice/errorDetection/ChangedMeaning.ice @@ -17,6 +17,7 @@ sequence<long> ls; struct s00 { ls ls; // OK as Ice 3.6 (data member has its own scope) + ls l; }; struct s0 @@ -124,7 +125,7 @@ interface ParamTest void op(long param); void op2(counter param); void param(counter counter); // OK as Ice 3.6 (parameters has its own scope) - void op3(long counter, counter x); // Second "counter" is not a type + void op3(long counter, counter x); // OK as Ice 3.6.1 (Second "counter" is not a type) void op4(long param, long param); }; |