blob: 999eaed618026284659591f902e8637afb0fae49 [file] [log] [blame]
Richard Smith0cdcc982013-01-29 01:24:26 +00001// RUN: %clang_cc1 -std=c++11 -ast-print -fms-extensions %s | FileCheck %s
Michael Hanaf02bbe2013-02-01 01:19:17 +00002//
3// CHECK: int x __attribute__((aligned(4)));
Michael Han99315932013-01-24 16:46:58 +00004int x __attribute__((aligned(4)));
5
Richard Smith0cdcc982013-01-29 01:24:26 +00006// FIXME: Print this at a valid location for a __declspec attr.
Michael Hanaf02bbe2013-02-01 01:19:17 +00007// CHECK: int y __declspec(align(4));
Richard Smith0cdcc982013-01-29 01:24:26 +00008__declspec(align(4)) int y;
Michael Han99315932013-01-24 16:46:58 +00009
Michael Hand9450f72013-02-26 02:00:13 +000010// CHECK: int z {{\[}}[gnu::aligned(4)]];
Michael Han99315932013-01-24 16:46:58 +000011int z [[gnu::aligned(4)]];
12
13// CHECK: __attribute__((deprecated("warning")));
14int a __attribute__((deprecated("warning")));
15
Michael Hand9450f72013-02-26 02:00:13 +000016// CHECK: int b {{\[}}[gnu::deprecated("warning")]];
Michael Han99315932013-01-24 16:46:58 +000017int b [[gnu::deprecated("warning")]];
18
Michael Hanaf02bbe2013-02-01 01:19:17 +000019// CHECK: int cxx11_alignas alignas(4);
Richard Smithd11c7a12013-01-29 01:48:07 +000020alignas(4) int cxx11_alignas;
21
Michael Hanaf02bbe2013-02-01 01:19:17 +000022// CHECK: int c11_alignas _Alignas(alignof(int));
Richard Smithd11c7a12013-01-29 01:48:07 +000023_Alignas(int) int c11_alignas;
24
Michael Han99315932013-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 Hand9450f72013-02-26 02:00:13 +000034// CHECK: {{\[}}[clang::warn_unused_result]];
Michael Han99315932013-01-24 16:46:58 +000035int f2 [[clang::warn_unused_result]] ();
36
Michael Hand9450f72013-02-26 02:00:13 +000037// CHECK: {{\[}}[gnu::warn_unused_result]];
Michael Han99315932013-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 Hand9450f72013-02-26 02:00:13 +000042// CHECK: {{\[}}[noreturn]];
Michael Han99315932013-01-24 16:46:58 +000043void f4 [[noreturn]] ();
44
Michael Han99315932013-01-24 16:46:58 +000045// CHECK: __attribute__((gnu_inline));
46inline void f6() __attribute__((gnu_inline));
47
Michael Hand9450f72013-02-26 02:00:13 +000048// CHECK: {{\[}}[gnu::gnu_inline]];
Michael Han99315932013-01-24 16:46:58 +000049inline void f7 [[gnu::gnu_inline]] ();
50
51// arguments printing
Aaron Ballmanf58070b2013-09-03 21:02:22 +000052// CHECK: __attribute__((format(printf, 2, 3)));
Michael Han99315932013-01-24 16:46:58 +000053void f8 (void *, const char *, ...) __attribute__ ((format (printf, 2, 3)));
Richard Smitha5aaca92013-01-29 04:21:28 +000054
55// CHECK: int m __attribute__((aligned(4
56// CHECK: int n alignas(4
57// CHECK: static int f() __attribute__((pure))
58// CHECK: static int g() {{\[}}[gnu::pure]]
59template <typename T> struct S {
60 __attribute__((aligned(4))) int m;
61 alignas(4) int n;
62 __attribute__((pure)) static int f() {
63 return 0;
64 }
65 [[gnu::pure]] static int g() {
66 return 1;
67 }
68};
69
70// CHECK: int m __attribute__((aligned(4
71// CHECK: int n alignas(4
72// CHECK: static int f() __attribute__((pure))
73// CHECK: static int g() {{\[}}[gnu::pure]]
74template struct S<int>;
Enea Zaffanellaa86d88c2013-06-20 12:46:19 +000075
76// CHECK: using Small2 {{\[}}[gnu::mode(byte)]] = int;
77using Small2 [[gnu::mode(byte)]] = int;