[PATCH] D71734: [Modules] Handle tag types and complain about bad merges in C/Objective-C mode

Volodymyr Sapsai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 11 14:56:30 PDT 2021


vsapsai added a comment.

Found another case that doesn't emit an error

  #if defined(FIRST)
  struct Indirect {
    int x;
  };
  struct Direct {
    struct Indirect i;
  };
  #elif defined(SECOND)
  struct Indirect {
    double a;
  };
  struct Direct {
    struct Indirect i;
  };
  #else
  struct Direct d;
  #endif

According to my debugging there is no error because `Direct` fields aren't deserialized in -fsyntax-only mode and therefore `Indirect` definitions aren't compared. But during IRGen there is diagnostic and that's because calculating record layout triggers full deserialization. Also there is diagnostic in C++ because we are dealing with default initialization and `DeclareImplicitDefaultConstructor` iterates through all the fields deserializing them.

I believe the best user experience is consistent diagnostic, so we should emit the error even with -fsyntax-only. If anybody has any objections, please let me know, it would save time.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71734/new/

https://reviews.llvm.org/D71734



More information about the cfe-commits mailing list