[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / SemaCXX / cxx11-attr-print.cpp
blobe7c00b76d038373376968064328537cfcae83d25
1 // RUN: %clang_cc1 -std=c++11 -ast-print -fms-extensions %s | FileCheck %s
2 //
3 // CHECK: int x __attribute__((aligned(4)));
4 int x __attribute__((aligned(4)));
6 // FIXME: Print this at a valid location for a __declspec attr.
7 // CHECK: int y __declspec(align(4));
8 __declspec(align(4)) int y;
10 // CHECK: int z {{\[}}[gnu::aligned(4)]];
11 int z [[gnu::aligned(4)]];
13 // CHECK: __attribute__((deprecated("warning")));
14 int a __attribute__((deprecated("warning")));
16 // CHECK: int b {{\[}}[gnu::deprecated("warning")]];
17 int b [[gnu::deprecated("warning")]];
19 // CHECK: __declspec(deprecated("warning"))
20 __declspec(deprecated("warning")) int c;
22 // CHECK: int d {{\[}}[deprecated("warning")]];
23 int d [[deprecated("warning")]];
25 // CHECK: __attribute__((deprecated("warning", "fixit")));
26 int e __attribute__((deprecated("warning", "fixit")));
28 // CHECK: int cxx11_alignas alignas(4);
29 alignas(4) int cxx11_alignas;
31 // CHECK: int c11_alignas _Alignas(alignof(int));
32 _Alignas(int) int c11_alignas;
34 // CHECK: void foo() __attribute__((const));
35 void foo() __attribute__((const));
37 // CHECK: void bar() __attribute__((__const));
38 void bar() __attribute__((__const));
40 // FIXME: It's unfortunate that the string literal prints with the below three
41 // cases given that the string is only exposed via the [[nodiscard]] spelling.
42 // CHECK: int f1() __attribute__((warn_unused_result("")));
43 int f1() __attribute__((warn_unused_result));
45 // CHECK: {{\[}}[clang::warn_unused_result("")]];
46 int f2 [[clang::warn_unused_result]] ();
48 // CHECK: {{\[}}[gnu::warn_unused_result("")]];
49 int f3 [[gnu::warn_unused_result]] ();
51 // FIXME: ast-print need to print C++11
52 // attribute after function declare-id.
53 // CHECK: {{\[}}[noreturn]];
54 void f4 [[noreturn]] ();
56 // CHECK: __attribute__((gnu_inline));
57 inline void f6() __attribute__((gnu_inline));
59 // CHECK: {{\[}}[gnu::gnu_inline]];
60 inline void f7 [[gnu::gnu_inline]] ();
62 // arguments printing
63 // CHECK: __attribute__((format(printf, 2, 3)));
64 void f8 (void *, const char *, ...) __attribute__ ((format (printf, 2, 3)));
66 // CHECK: int m __attribute__((aligned(4
67 // CHECK: int n alignas(4
68 // CHECK: static int f() __attribute__((pure))
69 // CHECK: static int g() {{\[}}[gnu::pure]]
70 template <typename T> struct S {
71 __attribute__((aligned(4))) int m;
72 alignas(4) int n;
73 __attribute__((pure)) static int f() {
74 return 0;
76 [[gnu::pure]] static int g() {
77 return 1;
81 // CHECK: int m __attribute__((aligned(4
82 // CHECK: int n alignas(4
83 // CHECK: static int f() __attribute__((pure))
84 // CHECK: static int g() {{\[}}[gnu::pure]]
85 template struct S<int>;
87 // CHECK: using Small2 {{\[}}[gnu::mode(byte)]] = int;
88 using Small2 [[gnu::mode(byte)]] = int;