blob: 12b41758c74df3c489358e6b31ff39d633018513 [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
Manman Renc7890fe2016-03-16 18:50:49 +000019// CHECK: __declspec(deprecated("warning"))
20__declspec(deprecated("warning")) int c;
21
22// CHECK: int d {{\[}}[deprecated("warning")]];
23int d [[deprecated("warning")]];
24
25// CHECK: __attribute__((deprecated("warning", "fixit")));
26int e __attribute__((deprecated("warning", "fixit")));
27
Michael Hanaf02bbe2013-02-01 01:19:17 +000028// CHECK: int cxx11_alignas alignas(4);
Richard Smithd11c7a12013-01-29 01:48:07 +000029alignas(4) int cxx11_alignas;
30
Michael Hanaf02bbe2013-02-01 01:19:17 +000031// CHECK: int c11_alignas _Alignas(alignof(int));
Richard Smithd11c7a12013-01-29 01:48:07 +000032_Alignas(int) int c11_alignas;
33
Michael Han99315932013-01-24 16:46:58 +000034// CHECK: void foo() __attribute__((const));
35void foo() __attribute__((const));
36
37// CHECK: void bar() __attribute__((__const));
38void bar() __attribute__((__const));
39
40// CHECK: int f1() __attribute__((warn_unused_result));
41int f1() __attribute__((warn_unused_result));
42
Michael Hand9450f72013-02-26 02:00:13 +000043// CHECK: {{\[}}[clang::warn_unused_result]];
Michael Han99315932013-01-24 16:46:58 +000044int f2 [[clang::warn_unused_result]] ();
45
Michael Hand9450f72013-02-26 02:00:13 +000046// CHECK: {{\[}}[gnu::warn_unused_result]];
Michael Han99315932013-01-24 16:46:58 +000047int f3 [[gnu::warn_unused_result]] ();
48
49// FIXME: ast-print need to print C++11
50// attribute after function declare-id.
Michael Hand9450f72013-02-26 02:00:13 +000051// CHECK: {{\[}}[noreturn]];
Michael Han99315932013-01-24 16:46:58 +000052void f4 [[noreturn]] ();
53
Michael Han99315932013-01-24 16:46:58 +000054// CHECK: __attribute__((gnu_inline));
55inline void f6() __attribute__((gnu_inline));
56
Michael Hand9450f72013-02-26 02:00:13 +000057// CHECK: {{\[}}[gnu::gnu_inline]];
Michael Han99315932013-01-24 16:46:58 +000058inline void f7 [[gnu::gnu_inline]] ();
59
60// arguments printing
Aaron Ballmanf58070b2013-09-03 21:02:22 +000061// CHECK: __attribute__((format(printf, 2, 3)));
Michael Han99315932013-01-24 16:46:58 +000062void f8 (void *, const char *, ...) __attribute__ ((format (printf, 2, 3)));
Richard Smitha5aaca92013-01-29 04:21:28 +000063
64// CHECK: int m __attribute__((aligned(4
65// CHECK: int n alignas(4
66// CHECK: static int f() __attribute__((pure))
67// CHECK: static int g() {{\[}}[gnu::pure]]
68template <typename T> struct S {
69 __attribute__((aligned(4))) int m;
70 alignas(4) int n;
71 __attribute__((pure)) static int f() {
72 return 0;
73 }
74 [[gnu::pure]] static int g() {
75 return 1;
76 }
77};
78
79// CHECK: int m __attribute__((aligned(4
80// CHECK: int n alignas(4
81// CHECK: static int f() __attribute__((pure))
82// CHECK: static int g() {{\[}}[gnu::pure]]
83template struct S<int>;
Enea Zaffanellaa86d88c2013-06-20 12:46:19 +000084
85// CHECK: using Small2 {{\[}}[gnu::mode(byte)]] = int;
86using Small2 [[gnu::mode(byte)]] = int;