You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by br...@apache.org on 2010/08/06 01:23:04 UTC

svn commit: r982825 - /incubator/thrift/trunk/compiler/cpp/src/parse/t_scope.h

Author: bryanduxbury
Date: Thu Aug  5 23:23:04 2010
New Revision: 982825

URL: http://svn.apache.org/viewvc?rev=982825&view=rev
Log:
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

Modified:
    incubator/thrift/trunk/compiler/cpp/src/parse/t_scope.h

Modified: incubator/thrift/trunk/compiler/cpp/src/parse/t_scope.h
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/compiler/cpp/src/parse/t_scope.h?rev=982825&r1=982824&r2=982825&view=diff
==============================================================================
--- incubator/thrift/trunk/compiler/cpp/src/parse/t_scope.h (original)
+++ incubator/thrift/trunk/compiler/cpp/src/parse/t_scope.h Thu Aug  5 23:23:04 2010
@@ -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) {