Richard Smith | 5cd532c | 2013-01-29 01:24:26 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -std=c++11 -ast-print -fms-extensions %s | FileCheck %s |
Michael Han | a31f65b | 2013-02-01 01:19:17 +0000 | [diff] [blame] | 2 | // |
| 3 | // CHECK: int x __attribute__((aligned(4))); |
Michael Han | 51d8c52 | 2013-01-24 16:46:58 +0000 | [diff] [blame] | 4 | int x __attribute__((aligned(4))); |
| 5 | |
Richard Smith | 5cd532c | 2013-01-29 01:24:26 +0000 | [diff] [blame] | 6 | // FIXME: Print this at a valid location for a __declspec attr. |
Michael Han | a31f65b | 2013-02-01 01:19:17 +0000 | [diff] [blame] | 7 | // CHECK: int y __declspec(align(4)); |
Richard Smith | 5cd532c | 2013-01-29 01:24:26 +0000 | [diff] [blame] | 8 | __declspec(align(4)) int y; |
Michael Han | 51d8c52 | 2013-01-24 16:46:58 +0000 | [diff] [blame] | 9 | |
Michael Han | d8be0ab | 2013-02-26 02:00:13 +0000 | [diff] [blame] | 10 | // CHECK: int z {{\[}}[gnu::aligned(4)]]; |
Michael Han | 51d8c52 | 2013-01-24 16:46:58 +0000 | [diff] [blame] | 11 | int z [[gnu::aligned(4)]]; |
| 12 | |
| 13 | // CHECK: __attribute__((deprecated("warning"))); |
| 14 | int a __attribute__((deprecated("warning"))); |
| 15 | |
Michael Han | d8be0ab | 2013-02-26 02:00:13 +0000 | [diff] [blame] | 16 | // CHECK: int b {{\[}}[gnu::deprecated("warning")]]; |
Michael Han | 51d8c52 | 2013-01-24 16:46:58 +0000 | [diff] [blame] | 17 | int b [[gnu::deprecated("warning")]]; |
| 18 | |
Michael Han | a31f65b | 2013-02-01 01:19:17 +0000 | [diff] [blame] | 19 | // CHECK: int cxx11_alignas alignas(4); |
Richard Smith | 33f04a2 | 2013-01-29 01:48:07 +0000 | [diff] [blame] | 20 | alignas(4) int cxx11_alignas; |
| 21 | |
Michael Han | a31f65b | 2013-02-01 01:19:17 +0000 | [diff] [blame] | 22 | // CHECK: int c11_alignas _Alignas(alignof(int)); |
Richard Smith | 33f04a2 | 2013-01-29 01:48:07 +0000 | [diff] [blame] | 23 | _Alignas(int) int c11_alignas; |
| 24 | |
Michael Han | 51d8c52 | 2013-01-24 16:46:58 +0000 | [diff] [blame] | 25 | // CHECK: void foo() __attribute__((const)); |
| 26 | void foo() __attribute__((const)); |
| 27 | |
| 28 | // CHECK: void bar() __attribute__((__const)); |
| 29 | void bar() __attribute__((__const)); |
| 30 | |
| 31 | // CHECK: int f1() __attribute__((warn_unused_result)); |
| 32 | int f1() __attribute__((warn_unused_result)); |
| 33 | |
Michael Han | d8be0ab | 2013-02-26 02:00:13 +0000 | [diff] [blame] | 34 | // CHECK: {{\[}}[clang::warn_unused_result]]; |
Michael Han | 51d8c52 | 2013-01-24 16:46:58 +0000 | [diff] [blame] | 35 | int f2 [[clang::warn_unused_result]] (); |
| 36 | |
Michael Han | d8be0ab | 2013-02-26 02:00:13 +0000 | [diff] [blame] | 37 | // CHECK: {{\[}}[gnu::warn_unused_result]]; |
Michael Han | 51d8c52 | 2013-01-24 16:46:58 +0000 | [diff] [blame] | 38 | int f3 [[gnu::warn_unused_result]] (); |
| 39 | |
| 40 | // FIXME: ast-print need to print C++11 |
| 41 | // attribute after function declare-id. |
Michael Han | d8be0ab | 2013-02-26 02:00:13 +0000 | [diff] [blame] | 42 | // CHECK: {{\[}}[noreturn]]; |
Michael Han | 51d8c52 | 2013-01-24 16:46:58 +0000 | [diff] [blame] | 43 | void f4 [[noreturn]] (); |
| 44 | |
Michael Han | d8be0ab | 2013-02-26 02:00:13 +0000 | [diff] [blame] | 45 | // CHECK: {{\[}}[std::noreturn]]; |
Michael Han | 51d8c52 | 2013-01-24 16:46:58 +0000 | [diff] [blame] | 46 | void f5 [[std::noreturn]] (); |
| 47 | |
| 48 | // CHECK: __attribute__((gnu_inline)); |
| 49 | inline void f6() __attribute__((gnu_inline)); |
| 50 | |
Michael Han | d8be0ab | 2013-02-26 02:00:13 +0000 | [diff] [blame] | 51 | // CHECK: {{\[}}[gnu::gnu_inline]]; |
Michael Han | 51d8c52 | 2013-01-24 16:46:58 +0000 | [diff] [blame] | 52 | inline void f7 [[gnu::gnu_inline]] (); |
| 53 | |
| 54 | // arguments printing |
| 55 | // CHECK: __attribute__((format("printf", 2, 3))); |
| 56 | void f8 (void *, const char *, ...) __attribute__ ((format (printf, 2, 3))); |
Richard Smith | 8f3aacc | 2013-01-29 04:21:28 +0000 | [diff] [blame] | 57 | |
| 58 | // CHECK: int m __attribute__((aligned(4 |
| 59 | // CHECK: int n alignas(4 |
| 60 | // CHECK: static int f() __attribute__((pure)) |
| 61 | // CHECK: static int g() {{\[}}[gnu::pure]] |
| 62 | template <typename T> struct S { |
| 63 | __attribute__((aligned(4))) int m; |
| 64 | alignas(4) int n; |
| 65 | __attribute__((pure)) static int f() { |
| 66 | return 0; |
| 67 | } |
| 68 | [[gnu::pure]] static int g() { |
| 69 | return 1; |
| 70 | } |
| 71 | }; |
| 72 | |
| 73 | // CHECK: int m __attribute__((aligned(4 |
| 74 | // CHECK: int n alignas(4 |
| 75 | // CHECK: static int f() __attribute__((pure)) |
| 76 | // CHECK: static int g() {{\[}}[gnu::pure]] |
| 77 | template struct S<int>; |