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