diff options
| author | Weiming Zhao <weimingz@codeaurora.org> | 2015-02-03 22:35:58 +0000 |
|---|---|---|
| committer | Weiming Zhao <weimingz@codeaurora.org> | 2015-02-03 22:35:58 +0000 |
| commit | 71ac240620c4fedb6e49c302c490e99bb2d37eb4 (patch) | |
| tree | 7e77100160781705607098aa9d51d08dfffc1970 /clang/test/Sema | |
| parent | ab1dc2d54db5fc2ad4ee748745420eac844a5ea3 (diff) | |
| download | bcm5719-llvm-71ac240620c4fedb6e49c302c490e99bb2d37eb4.tar.gz bcm5719-llvm-71ac240620c4fedb6e49c302c490e99bb2d37eb4.zip | |
Diagnose CXX 'this' pointer reference in funcs with naked attr
Clang asserts for this pointer reference in asms of naked functions.
This patch diagnoses if this pointer reference is used.
Differential Revision: http://reviews.llvm.org/D7329
llvm-svn: 228052
Diffstat (limited to 'clang/test/Sema')
| -rw-r--r-- | clang/test/Sema/attr-naked.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/test/Sema/attr-naked.cpp b/clang/test/Sema/attr-naked.cpp new file mode 100644 index 00000000000..eaa8e223b83 --- /dev/null +++ b/clang/test/Sema/attr-naked.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 %s -verify -fsyntax-only -triple arm-none-linux +class Foo { + void bar(); + static void bar2(); + unsigned v; + static unsigned s; +}; + +void __attribute__((naked)) Foo::bar() { // expected-note{{attribute is here}} + asm("mov r2, %0" : : "r"(v)); // expected-error{{'this' pointer references not allowed in naked functions}} +} + +void __attribute__((naked)) Foo::bar2() { + asm("mov r2, %0" : : "r"(s)); // static member reference is OK +} |

