[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Sema / attr-likelihood.c
blob2c34d29002268f0d8f074a4c63e9302c970c8096
1 // RUN: %clang_cc1 %s -fsyntax-only -fdouble-square-bracket-attributes -verify
3 void g(void) {
4 if (1)
5 [[clang::likely]] {}
7 void m(void) {
8 [[clang::likely]] int x = 42; // expected-error {{'likely' attribute cannot be applied to a declaration}}
10 if (x)
11 [[clang::unlikely]] {}
12 if (x) {
13 [[clang::unlikely]];
15 switch (x) {
16 case 1:
17 [[clang::likely]] {}
18 break;
19 [[clang::likely]] case 2 : case 3 : {}
20 break;
23 do {
24 [[clang::unlikely]];
25 } while (x);
27 [[clang::unlikely]] {}
28 while (x);
29 do { // expected-note {{to match this 'do'}}
31 [[clang::unlikely]] while (x); // expected-error {{expected 'while' in do/while loop}}
32 for (;;)
33 [[clang::unlikely]] {}
34 for (;;) {
35 [[clang::unlikely]];
37 while (x)
38 [[clang::unlikely]] {}
39 while (x) {
40 [[clang::unlikely]];
43 if (x)
44 goto lbl;
46 // FIXME: allow the attribute on the label
47 [[clang::unlikely]] lbl : // expected-error {{'unlikely' attribute cannot be applied to a declaration}}
48 [[clang::likely]] x = x + 1;
50 [[clang::likely]]++ x;