summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Slice/Parser.cpp14
1 files changed, 11 insertions, 3 deletions
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);
}
}