]> granicus.if.org Git - clang/commit
Unnamed bitfields don't block constant evaluation of constexpr ctors
authorJordan Rose <jordan_rose@apple.com>
Tue, 24 Oct 2017 02:17:07 +0000 (02:17 +0000)
committerJordan Rose <jordan_rose@apple.com>
Tue, 24 Oct 2017 02:17:07 +0000 (02:17 +0000)
commitbca81dc70a81c58378cc853256544386194ced1d
tree78c9ee657de4b2b5c3b85513acdc7ac93032d946
parentfbbb8c17f50e6bb450a12965d30ac47a12c9aa58
Unnamed bitfields don't block constant evaluation of constexpr ctors

C++14 [dcl.constexpr]p4 states that in the body of a constexpr
constructor,

> every non-variant non-static data member and base class sub-object
  shall be initialized

However, [class.bit]p2 notes that

> Unnamed bit-fields are not members and cannot be initialized.

Therefore, we should make sure to filter them out of the check that
all fields are initialized.

Fixing this makes the constant evaluator a bit smarter, and
specifically allows constexpr constructors to avoid tripping
-Wglobal-constructors when the type contains unnamed bitfields.

Reviewed at https://reviews.llvm.org/D39035.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316408 91177308-0d34-0410-b5e6-96231b3b80d8
lib/AST/ExprConstant.cpp
test/SemaCXX/constant-expression-cxx11.cpp
test/SemaCXX/warn-global-constructors.cpp