mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 14:36:06 +00:00

ARC mode. Declaring __strong pointer fields in structs was not allowed in Objective-C ARC until now because that would make the struct non-trivial to default-initialize, copy/move, and destroy, which is not something C was designed to do. This patch lifts that restriction. Special functions for non-trivial C structs are synthesized that are needed to default-initialize, copy/move, and destroy the structs and manage the ownership of the objects the __strong pointer fields point to. Non-trivial structs passed to functions are destructed in the callee function. rdar://problem/33599681 Differential Revision: https://reviews.llvm.org/D41228 llvm-svn: 326307
15 lines
395 B
Objective-C
15 lines
395 B
Objective-C
// RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -fblocks -fobjc-runtime=ios-11.0 -emit-llvm -verify -o - %s
|
|
|
|
typedef struct { // expected-error {{special function __default_constructor_8_s8 for non-trivial C struct has incorrect type}}
|
|
int i;
|
|
id f1;
|
|
} StrongSmall;
|
|
|
|
int __default_constructor_8_s8(double a) {
|
|
return 0;
|
|
}
|
|
|
|
void testIncorrectFunctionType(void) {
|
|
StrongSmall x;
|
|
}
|