Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def OpenCLKernelFunction
// inclusive nature of subject testing).
def HasFunctionProto : SubsetSubject<DeclBase,
[{(S->getFunctionType(true) != nullptr &&
isa<FunctionProtoType>(S->getFunctionType())) ||
isa<FunctionProtoType>(S->getFunctionType())) ||
isa<ObjCMethodDecl>(S) ||
isa<BlockDecl>(S)}],
"non-K&R-style functions">;
Expand Down
2 changes: 2 additions & 0 deletions clang/lib/AST/DeclBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,8 @@ const FunctionType *Decl::getFunctionType(bool BlocksToo) const {

if (Ty->isFunctionPointerType())
Ty = Ty->castAs<PointerType>()->getPointeeType();
else if (Ty->isMemberFunctionPointerType())
Ty = Ty->castAs<MemberPointerType>()->getPointeeType();
else if (Ty->isFunctionReferenceType())
Ty = Ty->castAs<ReferenceType>()->getPointeeType();
else if (BlocksToo && Ty->isBlockPointerType())
Expand Down
5 changes: 5 additions & 0 deletions clang/test/AST/attr-print-emit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,8 @@ ANNOTATE_ATTR NONNULL_ATTR void fn_non_null_annotated_attr(int *) __attribute__(

[[gnu::nonnull(1)]] [[gnu::always_inline]] void cxx11_attr(int*) ANNOTATE_ATTR;
// CHECK: {{\[\[}}gnu::nonnull(1)]] {{\[\[}}gnu::always_inline]] void cxx11_attr(int *) __attribute__((annotate("Annotated")));

struct Foo;

// CHECK: void as_member_fn_ptr(int *(Foo::*member)(int) __attribute__((alloc_size(1))));
void as_member_fn_ptr(int* (Foo::*member)(int) __attribute__((alloc_size(1))));
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// RUN: %clang_cc1 -triple aarch64 -target-feature +sme -target-feature +sme2 -x c++ -std=c++20 -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK

struct TestStruct;

__arm_new("za", "zt0") void test(TestStruct& TS,
void (TestStruct::*streaming_member_ptr)() __arm_streaming,
void (TestStruct::*streaming_compat_member)() __arm_streaming_compatible,
void (TestStruct::*arm_in_member)() __arm_in("za", "zt0"),
void (TestStruct::*arm_inout_member)() __arm_inout("za", "zt0"),
void (TestStruct::*arm_preserves_member)() __arm_preserves("za", "zt0"),
void (TestStruct::*arm_agnostic_member)() __arm_agnostic("sme_za_state")) {

// CHECK: call void %{{.*}} [[STREAMING_MEMBER_CALL_ATTRS:#.+]]
(TS.*streaming_member_ptr)();

// CHECK: call void %{{.*}} [[STREAMING_COMPAT_MEMBER_CALL_ATTRS:#.+]]
(TS.*streaming_compat_member)();

// CHECK: call void %{{.*}} [[ARM_IN_MEMBER_CALL_ATTRS:#.+]]
(TS.*arm_in_member)();

// CHECK: call void %{{.*}} [[ARM_INOUT_MEMBER_CALL_ATTRS:#.+]]
(TS.*arm_inout_member)();

// CHECK: call void %{{.*}} [[ARM_PRESERVES_MEMBER_CALL_ATTRS:#.+]]
(TS.*arm_preserves_member)();

// CHECK: call void %{{.*}} [[ARM_AGNOSTIC_MEMBER_CALL_ATTRS:#.+]]
(TS.*arm_agnostic_member)();
}

// CHECK: attributes [[STREAMING_MEMBER_CALL_ATTRS]] = { "aarch64_pstate_sm_enabled" }
// CHECK: attributes [[STREAMING_COMPAT_MEMBER_CALL_ATTRS]] = { "aarch64_pstate_sm_compatible" }
// CHECK: attributes [[ARM_IN_MEMBER_CALL_ATTRS]] = { "aarch64_in_za" "aarch64_in_zt0" }
// CHECK: attributes [[ARM_INOUT_MEMBER_CALL_ATTRS]] = { "aarch64_inout_za" "aarch64_inout_zt0" }
// CHECK: attributes [[ARM_PRESERVES_MEMBER_CALL_ATTRS]] = { "aarch64_preserves_za" "aarch64_preserves_zt0" }
// CHECK: attributes [[ARM_AGNOSTIC_MEMBER_CALL_ATTRS]] = { "aarch64_za_state_agnostic" }
10 changes: 10 additions & 0 deletions clang/test/CodeGen/xfail-alloc-align-fn-pointers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

// RUN: %clang_cc1 %s

// FIXME: These should not crash!
// XFAIL: *

void aa_fn_ptr(char* (*member)(char*) __attribute__((alloc_align(1))));

struct Test;
void aa_member_fn_ptr(char* (Test::*member)(char*) __attribute__((alloc_align(1))));