[PATCH] D42863: Make __has_unique_object_representations reject empty union types.

Eric Fiselier via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 2 12:34:06 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL324134: Make __has_unique_object_representations reject empty union types. (authored by EricWF, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42863?vs=132651&id=132656#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42863

Files:
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/test/SemaCXX/type-traits.cpp


Index: cfe/trunk/test/SemaCXX/type-traits.cpp
===================================================================
--- cfe/trunk/test/SemaCXX/type-traits.cpp
+++ cfe/trunk/test/SemaCXX/type-traits.cpp
@@ -2566,6 +2566,7 @@
 static_assert(!has_unique_object_representations<volatile int &>::value, "No references!");
 static_assert(!has_unique_object_representations<const volatile int &>::value, "No references!");
 static_assert(!has_unique_object_representations<Empty>::value, "No empty types!");
+static_assert(!has_unique_object_representations<EmptyUnion>::value, "No empty types!");
 
 class Compressed : Empty {
   int x;
Index: cfe/trunk/lib/AST/ASTContext.cpp
===================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp
+++ cfe/trunk/lib/AST/ASTContext.cpp
@@ -2145,7 +2145,7 @@
     if (FieldSize != UnionSize)
       return false;
   }
-  return true;
+  return !RD->field_empty();
 }
 
 static bool isStructEmpty(QualType Ty) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42863.132656.patch
Type: text/x-patch
Size: 985 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180202/9407976c/attachment.bin>


More information about the cfe-commits mailing list