mirror of https://github.com/microsoft/clang.git
Check that a field is not annotated with attribute "unavailable" before
setting the NonTrivialToPrimitive* flags of a record. Union fields that have non-trivial Objective-C ownership qualifications are normally not legal, but if the union is declared in a system header, the fields are annotated with attribute "unavailable". rdar://problem/38431072 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327464 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
08cdd81877
commit
cd5551fae6
|
@ -15442,7 +15442,7 @@ void Sema::ActOnFields(Scope *S, SourceLocation RecLoc, Decl *EnclosingDecl,
|
|||
}
|
||||
}
|
||||
|
||||
if (Record && !getLangOpts().CPlusPlus) {
|
||||
if (Record && !getLangOpts().CPlusPlus && !FD->hasAttr<UnavailableAttr>()) {
|
||||
QualType FT = FD->getType();
|
||||
if (FT.isNonTrivialToPrimitiveDefaultInitialize())
|
||||
Record->setNonTrivialToPrimitiveDefaultInitialize(true);
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#ifndef STRONG_IN_UNION_H
|
||||
#define STRONG_IN_UNION_H
|
||||
#pragma clang system_header
|
||||
|
||||
typedef union {
|
||||
id f0;
|
||||
int *f1;
|
||||
} U;
|
||||
|
||||
#endif // STRONG_IN_UNION_H
|
|
@ -1,10 +1,11 @@
|
|||
// RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -fblocks -fobjc-runtime=ios-11.0 -emit-llvm -o - -DUSESTRUCT %s | FileCheck %s
|
||||
// RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -fblocks -fobjc-runtime=ios-11.0 -emit-llvm -o - -DUSESTRUCT -I %S/Inputs %s | FileCheck %s
|
||||
|
||||
// RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -fblocks -fobjc-runtime=ios-11.0 -emit-pch -o %t %s
|
||||
// RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -fblocks -fobjc-runtime=ios-11.0 -include-pch %t -emit-llvm -o - -DUSESTRUCT %s | FileCheck %s
|
||||
// RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -fblocks -fobjc-runtime=ios-11.0 -emit-pch -I %S/Inputs -o %t %s
|
||||
// RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -fblocks -fobjc-runtime=ios-11.0 -include-pch %t -emit-llvm -o - -DUSESTRUCT -I %S/Inputs %s | FileCheck %s
|
||||
|
||||
#ifndef HEADER
|
||||
#define HEADER
|
||||
#include "strong_in_union.h"
|
||||
|
||||
typedef void (^BlockTy)(void);
|
||||
|
||||
|
@ -531,4 +532,12 @@ void test_copy_constructor_Bitfield1(Bitfield1 *a) {
|
|||
Bitfield1 t = *a;
|
||||
}
|
||||
|
||||
// CHECK: define void @test_strong_in_union()
|
||||
// CHECK: alloca %{{.*}}
|
||||
// CHECK-NEXT: ret void
|
||||
|
||||
void test_strong_in_union() {
|
||||
U t;
|
||||
}
|
||||
|
||||
#endif /* USESTRUCT */
|
||||
|
|
Loading…
Reference in New Issue