diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/CHANGES | 3 | ||||
-rw-r--r-- | cpp/src/Slice/Parser.cpp | 14 | ||||
-rw-r--r-- | cpp/test/Slice/errorDetection/ChangedMeaning.ice | 13 |
3 files changed, 27 insertions, 3 deletions
diff --git a/cpp/CHANGES b/cpp/CHANGES index 1c519d96da9..b7ee8fc3f78 100644 --- a/cpp/CHANGES +++ b/cpp/CHANGES @@ -1,6 +1,9 @@ Changes since version 1.2.0 --------------------------- +- Fixed an incorrect complaint in the Slice parser about + about a change of meaning for enumeration constant definitions. + - The glacierrouter and glacierstarter processes used to abort if given a non-existent config file. diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index a2c88bb5358..9bf4da734c6 100644 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -1594,17 +1594,25 @@ Slice::Container::checkIntroduced(const string& scoped, ContainedPtr namedThing) // // For each scope, get the container until we have the container // for the first scope (which is the introduced one). + // For enumeration constants, step up one additional step. This + // is necessary because, in the syntax tree, the enumerator has + // a container but, when naming the enumerator in the Slice source, + // the enumerator enters the enclosing scope. // ContainerPtr c; - while(pos != string::npos) + if(EnumeratorPtr::dynamicCast(namedThing)) { c = namedThing->container(); pos = scoped.find("::", pos + 2); } - if(c) + while(c && pos != string::npos) + { + c = ContainedPtr::dynamicCast(c)->container(); + pos = scoped.find("::", pos + 2); + } + if(ContainedPtr::dynamicCast(c)) { namedThing = ContainedPtr::dynamicCast(c); - assert(namedThing); } } diff --git a/cpp/test/Slice/errorDetection/ChangedMeaning.ice b/cpp/test/Slice/errorDetection/ChangedMeaning.ice index b1e5d3fadec..33b9bb4ffc5 100644 --- a/cpp/test/Slice/errorDetection/ChangedMeaning.ice +++ b/cpp/test/Slice/errorDetection/ChangedMeaning.ice @@ -158,3 +158,16 @@ interface Blah3 void op5() throws E::ee1; // Introduces E void E(); // Changed meaning }; + +module M1 +{ + module M2 + { + enum C { C1, C2, C3 }; + }; +}; + +const M1::M2::C MyConstant1 = M1::M2::C2; // OK +const ::M1::M2::C MyConstant2 = M1::M2::C2; // OK +const M1::M2::C MyConstant3 = ::M1::M2::C2; // OK +const ::M1::M2::C MyConstant4 = ::M1::M2::C2; // OK |