diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2011-10-12 19:51:18 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2011-10-12 19:51:18 +0000 |
| commit | 2d21ab024ed371ce2a45c8691d0676a4ed855cc1 (patch) | |
| tree | 41ec69341bd6b739149021a3287d76aa530ea02b /clang/test | |
| parent | a35d67dfd927191a16cf24931981d79901938381 (diff) | |
| download | bcm5719-llvm-2d21ab024ed371ce2a45c8691d0676a4ed855cc1.tar.gz bcm5719-llvm-2d21ab024ed371ce2a45c8691d0676a4ed855cc1.zip | |
Add returns_twice to functions that are known to return twice. This implements
the same behavior of gcc by keeping the attribute out of the function type.
llvm-svn: 141803
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Analysis/security-syntax-checks.m | 2 | ||||
| -rw-r--r-- | clang/test/CodeGen/function-attributes.c | 11 | ||||
| -rw-r--r-- | clang/test/Sema/attr-returns-twice.c | 12 |
3 files changed, 24 insertions, 1 deletions
diff --git a/clang/test/Analysis/security-syntax-checks.m b/clang/test/Analysis/security-syntax-checks.m index a04401b531f..6fb5b3cf14e 100644 --- a/clang/test/Analysis/security-syntax-checks.m +++ b/clang/test/Analysis/security-syntax-checks.m @@ -170,7 +170,7 @@ void test_strcat() { //===----------------------------------------------------------------------=== typedef int __int32_t; typedef __int32_t pid_t; -pid_t vfork(void); +pid_t vfork(void); //expected-warning{{declaration of built-in function 'vfork' requires inclusion of the header <setjmp.h>}} void test_vfork() { vfork(); //expected-warning{{Call to function 'vfork' is insecure as it can lead to denial of service situations in the parent process.}} diff --git a/clang/test/CodeGen/function-attributes.c b/clang/test/CodeGen/function-attributes.c index fd98458c842..6cbf40ba220 100644 --- a/clang/test/CodeGen/function-attributes.c +++ b/clang/test/CodeGen/function-attributes.c @@ -100,3 +100,14 @@ __attribute__ ((returns_twice)) void f17(void); __attribute__ ((returns_twice)) void f18(void) { f17(); } + +// CHECK: define void @f19() +// CHECK: { +// CHECK: call i32 @setjmp(i32* null) +// CHECK: returns_twice +// CHECK: ret void +typedef int jmp_buf[((9 * 2) + 3 + 16)]; +int setjmp(jmp_buf); +void f19(void) { + setjmp(0); +} diff --git a/clang/test/Sema/attr-returns-twice.c b/clang/test/Sema/attr-returns-twice.c new file mode 100644 index 00000000000..13f53e36de7 --- /dev/null +++ b/clang/test/Sema/attr-returns-twice.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 %s -verify -fsyntax-only + +int a __attribute__((returns_twice)); // expected-warning {{'returns_twice' attribute only applies to functions}} + +__attribute__((returns_twice)) void t0(void) { +} + +void t1() __attribute__((returns_twice)); + +void t2() __attribute__((returns_twice(2))); // expected-error {{attribute takes no arguments}} + +typedef void (*t3)(void) __attribute__((returns_twice)); // expected-warning {{'returns_twice' attribute only applies to functions}} |

