Disallow duplicated argument name or result name.

Test: compiles
Test: hidl-gen -Lc++ -r tests:system/tools/hidl/test \
-r android.hidl:system/libhidl/transport -o ~/temp \
    tests.errors.syntax@1.0

Bug: 33277700
Change-Id: I67c0f8df1a23b1155664aa448d8422953a8a77c5
diff --git a/hidl-gen_y.yy b/hidl-gen_y.yy
index 4f932e5..9c0e75b 100644
--- a/hidl-gen_y.yy
+++ b/hidl-gen_y.yy
@@ -268,7 +268,7 @@
     android::ConstantExpression *constantExpression;
     std::vector<android::EnumValue *> *enumValues;
     android::TypedVar *typedVar;
-    std::vector<android::TypedVar *> *typedVars;
+    android::TypedVarVector *typedVars;
     android::Method *method;
     android::CompoundType::Style compoundStyle;
     std::vector<std::string> *stringVec;
@@ -746,17 +746,25 @@
 typed_vars
     : /* empty */
       {
-          $$ = new std::vector<TypedVar *>;
+          $$ = new TypedVarVector();
       }
     | typed_var
       {
-          $$ = new std::vector<TypedVar *>;
-          $$->push_back($1);
+          $$ = new TypedVarVector();
+          if (!$$->add($1)) {
+              std::cerr << "ERROR: duplicated argument or result name "
+                  << $1->name() << " at " << @1 << "\n";
+              ast->addSyntaxError();
+          }
       }
     | typed_vars ',' typed_var
       {
           $$ = $1;
-          $$->push_back($3);
+          if (!$$->add($3)) {
+              std::cerr << "ERROR: duplicated argument or result name "
+                  << $3->name() << " at " << @3 << "\n";
+              ast->addSyntaxError();
+          }
       }
     ;