]> granicus.if.org Git - clang/commit
Make __has_unique_object_representations reject empty union types.
authorEric Fiselier <eric@efcs.ca>
Fri, 2 Feb 2018 20:30:39 +0000 (20:30 +0000)
committerEric Fiselier <eric@efcs.ca>
Fri, 2 Feb 2018 20:30:39 +0000 (20:30 +0000)
commit94aa2dbfab63948a4110733b9bbaf40bbf0b4e77
treef978a3568fac06afc44f6bb7f55b5ac61e4ed0b1
parent875d3fe57685b5c3a121140f9f1fb4ad123be678
Make __has_unique_object_representations reject empty union types.

Summary:
Clang incorrectly reports empty unions as having a unique object representation. However, this is not correct since `sizeof(EmptyUnion) == 1` AKA it has 8 bits of padding. Therefore it should be treated the same as an empty struct and report `false`.

@erichkeane also suggested this fix should be merged into the 6.0 release branch, so the initial release of `__has_unique_object_representations` is as bug-free as possible.

Reviewers: erichkeane, rsmith, aaron.ballman, majnemer

Reviewed By: erichkeane

Subscribers: cfe-commits, erichkeane

Differential Revision: https://reviews.llvm.org/D42863

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324134 91177308-0d34-0410-b5e6-96231b3b80d8
lib/AST/ASTContext.cpp
test/SemaCXX/type-traits.cpp