From 8fc413fbfd721080d5e8e0300d1094387cdeda15 Mon Sep 17 00:00:00 2001 From: Bryan Duxbury Date: Thu, 5 Aug 2010 23:23:04 +0000 Subject: [PATCH] THRIFT-554. multiple enums with the same key generate invalid code This patch causes multiple enums with the same name to trigger a parser error. Patch: Ben Taitelbaum git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@982825 13f79535-47bb-0310-9956-ffa450edef68 --- compiler/cpp/src/parse/t_scope.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/cpp/src/parse/t_scope.h b/compiler/cpp/src/parse/t_scope.h index 585b9107..91ec3127 100644 --- a/compiler/cpp/src/parse/t_scope.h +++ b/compiler/cpp/src/parse/t_scope.h @@ -60,7 +60,12 @@ class t_scope { } void add_constant(std::string name, t_const* constant) { - constants_[name] = constant; + if (constants_.find(name) != constants_.end()) { + throw "Enum " + name + " is already defined!"; + } else { + constants_[name] = constant; + } + } t_const* get_constant(std::string name) { -- 2.17.1