[PATCH] D34510: Teach clang how to merge typedef over anonymous structs in C mode.

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 26 13:42:46 PDT 2017

rsmith added a comment.

https://reviews.llvm.org/D31778 is related. We need to have a design for how ODR-like issues in C will be resolved before we'll know what the right fix is here. Prior to https://reviews.llvm.org/D31778 my intention had been to implement C's structural typing ("compatible type") rules and keep multiple definitions of `RecordDecl`s in C as separate entities, but https://reviews.llvm.org/D31778 is suggesting that we use something more ODR-like instead, which is also more in line with the direction that this patch takes.

It's notable that C has no notion of "typedef name for linkage", so this patch does not address all the typedef-related issues that might show up in C code. For example:

  typedef struct { ... } *ptr;

in two different modules would not be merged into a single type with this approach (you'd need to actually implement the C compatible type rules to get that to work). But maybe that's OK -- the above also does not (formally) work in C++, and it doesn't seem to cause major problems.



More information about the cfe-commits mailing list