[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Sema / attr-naked.cpp
bloba9c0fed4b99fca58a6bcdd63d12dfb2782697964
1 // RUN: %clang_cc1 %s -verify -fsyntax-only -triple arm-none-linux
2 // RUN: %clang_cc1 %s -verify -fsyntax-only -fms-compatibility -DDECLSPEC -triple i686-pc-win32
4 class Foo {
5 void bar();
6 static void bar2();
7 unsigned v;
8 static unsigned s;
9 };
11 void __attribute__((naked)) Foo::bar() { // expected-note{{attribute is here}}
12 asm("mov r2, %0" : : "r"(v)); // expected-error{{'this' pointer references not allowed in naked functions}}
15 void __attribute__((naked)) Foo::bar2() {
16 asm("mov r2, %0" : : "r"(s)); // static member reference is OK
19 struct Bar {
20 #ifdef DECLSPEC
21 __declspec(naked) void func1(); // expected-error {{'naked' attribute only applies to non-member functions}}
22 __declspec(naked) static void func2(); // expected-error {{'naked' attribute only applies to non-member functions}}
23 #endif
24 __attribute__((naked)) void func3(); // OK
25 __attribute__((naked)) static void func4(); // OK