[PATCH] Fix recognition of empty structures/unions

Serge Pavlov sepavloff at gmail.com
Sat Jun 8 06:42:34 PDT 2013


  Committed in revision r183609.


================
Comment at: lib/Sema/SemaDecl.cpp:11145
@@ +11144,3 @@
+        } else
+          UnnamedOnly = ZeroSize = false;
+      }
----------------
Richard Smith wrote:
> "ZeroSize = false;" is not always correct here. The field type might be of zero size itself. Use "Context.getTypeSizeInChars(I->getType()).isZero()" maybe?
Yes, getting type size allows recognition of zero-size types that the presented patch does not, for instance:

struct A1 {};
struct B1 { struct A1 a1; };

However call to getTypeSizeInChars causes change in type order, so some tests fail. This approach will be implemented later.


http://llvm-reviews.chandlerc.com/D578



More information about the cfe-commits mailing list