blob: 19de5b5a640b19b6b3668cb1b24df403043821c7 [file] [log] [blame]
Richard Smith5cd532c2013-01-29 01:24:26 +00001// RUN: %clang_cc1 -std=c++11 -ast-print -fms-extensions %s | FileCheck %s
Michael Hana31f65b2013-02-01 01:19:17 +00002//
3// CHECK: int x __attribute__((aligned(4)));
Michael Han51d8c522013-01-24 16:46:58 +00004int x __attribute__((aligned(4)));
5
Richard Smith5cd532c2013-01-29 01:24:26 +00006// FIXME: Print this at a valid location for a __declspec attr.
Michael Hana31f65b2013-02-01 01:19:17 +00007// CHECK: int y __declspec(align(4));
Richard Smith5cd532c2013-01-29 01:24:26 +00008__declspec(align(4)) int y;
Michael Han51d8c522013-01-24 16:46:58 +00009
Michael Hand8be0ab2013-02-26 02:00:13 +000010// CHECK: int z {{\[}}[gnu::aligned(4)]];
Michael Han51d8c522013-01-24 16:46:58 +000011int z [[gnu::aligned(4)]];
12
13// CHECK: __attribute__((deprecated("warning")));
14int a __attribute__((deprecated("warning")));
15
Michael Hand8be0ab2013-02-26 02:00:13 +000016// CHECK: int b {{\[}}[gnu::deprecated("warning")]];
Michael Han51d8c522013-01-24 16:46:58 +000017int b [[gnu::deprecated("warning")]];
18
Michael Hana31f65b2013-02-01 01:19:17 +000019// CHECK: int cxx11_alignas alignas(4);
Richard Smith33f04a22013-01-29 01:48:07 +000020alignas(4) int cxx11_alignas;
21
Michael Hana31f65b2013-02-01 01:19:17 +000022// CHECK: int c11_alignas _Alignas(alignof(int));
Richard Smith33f04a22013-01-29 01:48:07 +000023_Alignas(int) int c11_alignas;
24
Michael Han51d8c522013-01-24 16:46:58 +000025// CHECK: void foo() __attribute__((const));
26void foo() __attribute__((const));
27
28// CHECK: void bar() __attribute__((__const));
29void bar() __attribute__((__const));
30
31// CHECK: int f1() __attribute__((warn_unused_result));
32int f1() __attribute__((warn_unused_result));
33
Michael Hand8be0ab2013-02-26 02:00:13 +000034// CHECK: {{\[}}[clang::warn_unused_result]];
Michael Han51d8c522013-01-24 16:46:58 +000035int f2 [[clang::warn_unused_result]] ();
36
Michael Hand8be0ab2013-02-26 02:00:13 +000037// CHECK: {{\[}}[gnu::warn_unused_result]];
Michael Han51d8c522013-01-24 16:46:58 +000038int f3 [[gnu::warn_unused_result]] ();
39
40// FIXME: ast-print need to print C++11
41// attribute after function declare-id.
Michael Hand8be0ab2013-02-26 02:00:13 +000042// CHECK: {{\[}}[noreturn]];
Michael Han51d8c522013-01-24 16:46:58 +000043void f4 [[noreturn]] ();
44
Michael Hand8be0ab2013-02-26 02:00:13 +000045// CHECK: {{\[}}[std::noreturn]];
Michael Han51d8c522013-01-24 16:46:58 +000046void f5 [[std::noreturn]] ();
47
48// CHECK: __attribute__((gnu_inline));
49inline void f6() __attribute__((gnu_inline));
50
Michael Hand8be0ab2013-02-26 02:00:13 +000051// CHECK: {{\[}}[gnu::gnu_inline]];
Michael Han51d8c522013-01-24 16:46:58 +000052inline void f7 [[gnu::gnu_inline]] ();
53
54// arguments printing
55// CHECK: __attribute__((format("printf", 2, 3)));
56void f8 (void *, const char *, ...) __attribute__ ((format (printf, 2, 3)));
Richard Smith8f3aacc2013-01-29 04:21:28 +000057
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]]
62template <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]]
77template struct S<int>;