diff options
author | DeLesley Hutchins <delesley@google.com> | 2012-02-16 16:50:43 +0000 |
---|---|---|
committer | DeLesley Hutchins <delesley@google.com> | 2012-02-16 16:50:43 +0000 |
commit | 3fc6e4a7cda90e816cb8213bea927c9067cb6424 (patch) | |
tree | 38059a0c42e6faa08b340afa04f2f015c5ab052f /clang/test/Parser/attributes.c | |
parent | 9bc9bcc2472373ab81a2106e5a04fc6037e19fcc (diff) | |
download | bcm5719-llvm-3fc6e4a7cda90e816cb8213bea927c9067cb6424.tar.gz bcm5719-llvm-3fc6e4a7cda90e816cb8213bea927c9067cb6424.zip |
Allow thread safety attributes on function definitions.
For compatibility with gcc, clang will now parse gcc attributes on
function definitions, but issue a warning if the attribute is not a
thread safety attribute. Warning controlled by -Wgcc-compat.
llvm-svn: 150698
Diffstat (limited to 'clang/test/Parser/attributes.c')
-rw-r--r-- | clang/test/Parser/attributes.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/clang/test/Parser/attributes.c b/clang/test/Parser/attributes.c index 36bd8071ac5..347cb9c1bfb 100644 --- a/clang/test/Parser/attributes.c +++ b/clang/test/Parser/attributes.c @@ -61,3 +61,38 @@ int aligned(int); int __attribute__((vec_type_hint(char, aligned(16) )) missing_rparen_1; // expected-error {{expected ')'}} int __attribute__((mode(x aligned(16) )) missing_rparen_2; // expected-error {{expected ')'}} int __attribute__((format(printf, 0 aligned(16) )) missing_rparen_3; // expected-error {{expected ')'}} + + + +int testFundef1(int *a) __attribute__((nonnull(1))) { // \ + // expected-warning {{GCC does not allow nonnull attribute in this position on a function definition}} + return *a; +} + +// noreturn is lifted to type qualifier +void testFundef2() __attribute__((noreturn)) { // \ + // expected-warning {{GCC does not allow noreturn attribute in this position on a function definition}} + testFundef2(); +} + +int testFundef3(int *a) __attribute__((nonnull(1), // \ + // expected-warning {{GCC does not allow nonnull attribute in this position on a function definition}} + pure)) { // \ + // expected-warning {{GCC does not allow pure attribute in this position on a function definition}} + return *a; +} + +int testFundef4(int *a) __attribute__((nonnull(1))) // \ + // expected-warning {{GCC does not allow nonnull attribute in this position on a function definition}} + __attribute((pure)) { // \ + // expected-warning {{GCC does not allow pure attribute in this position on a function definition}} + return *a; +} + +// GCC allows these +void testFundef5() __attribute__(()) { } + +__attribute__((pure)) int testFundef6(int a) { return a; } + + + |