anchor.diff:              dict:store(MsgName, [Occurrence], D)
       end.
   
  +find_fixlen_types(Defs) ->
  +    fold_msg_fields(
  +      fun(_, #field{type=Type, occurrence=Occ}=FieldDef, Acc) ->
  +              IsPacked = is_packed(FieldDef),
  +              FixlenTypeInfo = #ft{type       = Type,
  +                                   occurrence = Occ,
  +                                   is_packed  = IsPacked},
  +              case Type of
  +                  fixed32  -> sets:add_element(FixlenTypeInfo, Acc);
  +                  sfixed32 -> sets:add_element(FixlenTypeInfo, Acc);
  +                  float    -> sets:add_element(FixlenTypeInfo, Acc);
  +                  fixed64  -> sets:add_element(FixlenTypeInfo, Acc);
  +                  sfixed64 -> sets:add_element(FixlenTypeInfo, Acc);
  +                  double   -> sets:add_element(FixlenTypeInfo, Acc);
  +                  _        -> Acc
  +              end
  +      end,
  +      sets:new(),
  +      Defs).
  +
  +find_packed_fields(Defs) ->
  +    fold_msg_fields(fun(MsgName, #field{name=FName}=FieldDef, Acc) ->
  +                            case is_packed(FieldDef) of
  +                                true  -> sets:add_element({MsgName,FName}, Acc);
  +                                false -> Acc
  +                            end
  +                    end,
  +                    sets:new(),
  +                    Defs).
   
   fold_msg_fields(Fun, InitAcc, Defs) ->
       lists:foldl(fun({{msg, MsgName}, Fields}, Acc) ->
  
positive.code: analyze_defs(Defs) ->
      #anres{used_types      = find_used_types(Defs),
             known_msg_size  = find_msgsizes_known_at_compile_time(Defs),
             msg_occurrences = find_msg_occurrences(Defs)}.
  
  find_used_types(Defs) ->
      fold_msg_fields(fun(_MsgName, #field{type=Type}, Acc) ->
  
negative.code: -include_lib("eunit/include/eunit.hrl").
  -include("../include/gpb.hrl").
  
  -record(ft, {type, occurrence, is_packed}).
  -record(anres, %% result of analysis
          {
            used_types      :: set(),  %% gpb_field_type()
            known_msg_size  :: dict(), %% MsgName -> Size | undefined
            msg_occurrences :: dict(), %% MsgName -> [occurrence()]
            fixlen_types    :: set(),  %% #ft{}
            packed_fields   :: set()   %% {MsgName,FieldName}
          }).
  
  
  