diff options
Diffstat (limited to 'clang/test')
4 files changed, 48 insertions, 0 deletions
diff --git a/clang/test/CodeGen/patchable-function-entry.c b/clang/test/CodeGen/patchable-function-entry.c new file mode 100644 index 00000000000..678d90ff78f --- /dev/null +++ b/clang/test/CodeGen/patchable-function-entry.c @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -triple aarch64 -emit-llvm %s -o - | FileCheck %s + +// CHECK: define void @f0() #0 +__attribute__((patchable_function_entry(0))) void f0() {} + +// CHECK: define void @f00() #0 +__attribute__((patchable_function_entry(0, 0))) void f00() {} + +// CHECK: define void @f2() #1 +__attribute__((patchable_function_entry(2))) void f2() {} + +// CHECK: define void @f20() #1 +__attribute__((patchable_function_entry(2, 0))) void f20() {} + +// CHECK: define void @f20decl() #1 +__attribute__((patchable_function_entry(2, 0))) void f20decl(); +void f20decl() {} + +/// M in patchable_function_entry(N,M) is currently ignored. +// CHECK: attributes #0 = { {{.*}} "patchable-function-entry"="0" +// CHECK: attributes #1 = { {{.*}} "patchable-function-entry"="2" diff --git a/clang/test/Misc/pragma-attribute-supported-attributes-list.test b/clang/test/Misc/pragma-attribute-supported-attributes-list.test index ef518cdd1be..76401ef46b6 100644 --- a/clang/test/Misc/pragma-attribute-supported-attributes-list.test +++ b/clang/test/Misc/pragma-attribute-supported-attributes-list.test @@ -128,6 +128,7 @@ // CHECK-NEXT: Owner (SubjectMatchRule_record_not_is_union) // CHECK-NEXT: ParamTypestate (SubjectMatchRule_variable_is_parameter) // CHECK-NEXT: PassObjectSize (SubjectMatchRule_variable_is_parameter) +// CHECK-NEXT: PatchableFunctionEntry (SubjectMatchRule_function, SubjectMatchRule_objc_method) // CHECK-NEXT: Pointer (SubjectMatchRule_record_not_is_union) // CHECK-NEXT: ReleaseHandle (SubjectMatchRule_variable_is_parameter) // CHECK-NEXT: RenderScriptKernel (SubjectMatchRule_function) diff --git a/clang/test/Sema/patchable-function-entry-attr.c b/clang/test/Sema/patchable-function-entry-attr.c new file mode 100644 index 00000000000..f807bd45e42 --- /dev/null +++ b/clang/test/Sema/patchable-function-entry-attr.c @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -triple aarch64 -fsyntax-only -verify %s + +// expected-error@+1 {{'patchable_function_entry' attribute takes at least 1 argument}} +__attribute__((patchable_function_entry)) void f(); + +// expected-error@+1 {{'patchable_function_entry' attribute takes no more than 2 arguments}} +__attribute__((patchable_function_entry(0, 0, 0))) void f(); + +// expected-error@+1 {{'patchable_function_entry' attribute requires a non-negative integral compile time constant expression}} +__attribute__((patchable_function_entry(-1))) void f(); + +int i; +// expected-error@+1 {{'patchable_function_entry' attribute requires parameter 0 to be an integer constant}} +__attribute__((patchable_function_entry(i))) void f(); + +// expected-error@+1 {{'patchable_function_entry' attribute requires integer constant between 0 and 0 inclusive}} +__attribute__((patchable_function_entry(1, 1))) void f(); diff --git a/clang/test/Sema/patchable-function-entry-attr.cpp b/clang/test/Sema/patchable-function-entry-attr.cpp new file mode 100644 index 00000000000..c443b2d01cf --- /dev/null +++ b/clang/test/Sema/patchable-function-entry-attr.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -triple aarch64 -fsyntax-only -verify=silence %s +// RUN: %clang_cc1 -triple i386 -fsyntax-only -verify=silence %s +// RUN: %clang_cc1 -triple x86_64 -fsyntax-only -verify=silence %s +// RUN: %clang_cc1 -triple ppc64le -fsyntax-only -verify %s + +// silence-no-diagnostics + +// expected-warning@+1 {{unknown attribute 'patchable_function_entry' ignored}} +[[gnu::patchable_function_entry(0)]] void f(); |

