diff --git a/compiler/cpp/src/thrifty.yy b/compiler/cpp/src/thrifty.yy
index 7b2072b..ef4b070 100644
--- a/compiler/cpp/src/thrifty.yy
+++ b/compiler/cpp/src/thrifty.yy
@@ -42,6 +42,8 @@
  */
 int y_field_val = -1;
 int g_arglist = 0;
+const int struct_is_struct = 0;
+const int struct_is_union = 1;
 
 %}
 
@@ -193,10 +195,10 @@ int g_arglist = 0;
 %type<tconstv>   ConstMap
 %type<tconstv>   ConstMapContents
 
+%type<iconst>    StructHead
 %type<tstruct>   Struct
 %type<tstruct>   Xception
 %type<tservice>  Service
-%type<tstruct>   Union
 
 %type<tfunction> Function
 %type<ttype>     FunctionType
@@ -471,13 +473,6 @@ TypeDefinition:
         g_program->add_struct($1);
       }
     }
-| Union
-    {
-      pdebug("TypeDefinition -> Union");
-      if (g_parse_mode == PROGRAM) {
-        g_program->add_union($1);
-      }
-    }
 | Xception
     {
       pdebug("TypeDefinition -> Xception");
@@ -687,25 +682,22 @@ ConstMapContents:
       $$->set_map();
     }
 
-Struct:
-  tok_struct tok_identifier XsdAll '{' FieldList '}' TypeAnnotations
+StructHead:
+  tok_struct
     {
-      pdebug("Struct -> tok_struct tok_identifier { FieldList }");
-      $5->set_xsd_all($3);
-      $$ = $5;
-      $$->set_name($2);
-      if ($7 != NULL) {
-        $$->annotations_ = $7->annotations_;
-        delete $7;
-      }
+      $$ = struct_is_struct;
+    }
+| tok_union
+    {
+      $$ = struct_is_union;
     }
 
-Union:
-  tok_union tok_identifier XsdAll '{' FieldList '}' TypeAnnotations
+Struct:
+  StructHead tok_identifier XsdAll '{' FieldList '}' TypeAnnotations
     {
-      pdebug("Union -> tok_union tok_identifier { FieldList }");
+      pdebug("Struct -> tok_struct tok_identifier { FieldList }");
       $5->set_xsd_all($3);
-      $5->set_union(true);
+      $5->set_union($1 == struct_is_union);
       $$ = $5;
       $$->set_name($2);
       if ($7 != NULL) {
