Thrift compiler now enforces uniqueness of field identifiers
Summary: The code would either not generate, or generate code with errors, if you did this beforehand. Now it's a die-fast stop hard error since this is absolultely always a wrong thing to do.
Reviewed By: dreiss
Test Plan: Test compiling a .thrift file with a repeated field identifier in a struct or arglist.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665379 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/parse/t_struct.h b/compiler/cpp/src/parse/t_struct.h
index 39da110..bca51f6 100644
--- a/compiler/cpp/src/parse/t_struct.h
+++ b/compiler/cpp/src/parse/t_struct.h
@@ -85,6 +85,17 @@
}
}
+ bool validate_field(t_field* field) {
+ int key = field->get_key();
+ std::vector<t_field*>::const_iterator m_iter;
+ for (m_iter = members_.begin(); m_iter != members_.end(); ++m_iter) {
+ if ((*m_iter)->get_key() == key) {
+ return false;
+ }
+ }
+ return true;
+ }
+
private:
std::vector<t_field*> members_;