r286189 - Correctly ignore unnamed bit-fields when checking whether a union has fields.
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 7 17:07:27 PST 2016
Author: rsmith
Date: Mon Nov 7 19:07:26 2016
New Revision: 286189
URL: http://llvm.org/viewvc/llvm-project?rev=286189&view=rev
Log:
Correctly ignore unnamed bit-fields when checking whether a union has fields.
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CodeGenCXX/mangle-unnamed.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=286189&r1=286188&r2=286189&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Nov 7 19:07:26 2016
@@ -6657,8 +6657,13 @@ bool SpecialMemberDeletionInfo::shouldDe
bool SpecialMemberDeletionInfo::shouldDeleteForAllConstMembers() {
// This is a silly definition, because it gives an empty union a deleted
// default constructor. Don't do that.
- if (CSM == Sema::CXXDefaultConstructor && inUnion() && AllFieldsAreConst &&
- !MD->getParent()->field_empty()) {
+ if (CSM == Sema::CXXDefaultConstructor && inUnion() && AllFieldsAreConst) {
+ bool AnyFields = false;
+ for (auto *F : MD->getParent()->fields())
+ if ((AnyFields = !F->isUnnamedBitfield()))
+ break;
+ if (!AnyFields)
+ return false;
if (Diagnose)
S.Diag(MD->getParent()->getLocation(),
diag::note_deleted_default_ctor_all_const)
Modified: cfe/trunk/test/CodeGenCXX/mangle-unnamed.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-unnamed.cpp?rev=286189&r1=286188&r2=286189&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-unnamed.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-unnamed.cpp Mon Nov 7 19:07:26 2016
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin10 | FileCheck %s
+// RUN: %clang_cc1 -std=c++98 -emit-llvm %s -o - -triple=x86_64-apple-darwin10 | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=x86_64-apple-darwin10 | FileCheck %s
struct S {
virtual ~S() { }
More information about the cfe-commits
mailing list