annotate clang/test/Sema/fallthrough-attr.c @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -fsyntax-only -std=gnu89 -verify -Wimplicit-fallthrough %s
anatofuz
parents:
diff changeset
2 // RUN: %clang_cc1 -fsyntax-only -std=gnu99 -verify -Wimplicit-fallthrough %s
anatofuz
parents:
diff changeset
3 // RUN: %clang_cc1 -fsyntax-only -std=c99 -verify -Wimplicit-fallthrough %s
anatofuz
parents:
diff changeset
4 // RUN: %clang_cc1 -fsyntax-only -std=c11 -verify -Wimplicit-fallthrough %s
anatofuz
parents:
diff changeset
5 // RUN: %clang_cc1 -fsyntax-only -std=c2x -DC2X -verify -Wimplicit-fallthrough %s
anatofuz
parents:
diff changeset
6
anatofuz
parents:
diff changeset
7 int fallthrough_attribute_spelling(int n) {
anatofuz
parents:
diff changeset
8 switch (n) {
anatofuz
parents:
diff changeset
9 case 0:
anatofuz
parents:
diff changeset
10 n++;
anatofuz
parents:
diff changeset
11 case 1:
anatofuz
parents:
diff changeset
12 #if defined(C2X)
anatofuz
parents:
diff changeset
13 // expected-warning@-2{{unannotated fall-through between switch labels}} expected-note@-2{{insert '[[fallthrough]];' to silence this warning}} expected-note@-2{{insert 'break;' to avoid fall-through}}
anatofuz
parents:
diff changeset
14 #else
anatofuz
parents:
diff changeset
15 // expected-warning@-4{{unannotated fall-through between switch labels}} expected-note@-4{{insert '__attribute__((fallthrough));' to silence this warning}} expected-note@-4{{insert 'break;' to avoid fall-through}}
anatofuz
parents:
diff changeset
16 #endif
anatofuz
parents:
diff changeset
17 n++;
anatofuz
parents:
diff changeset
18 __attribute__((fallthrough));
anatofuz
parents:
diff changeset
19 case 2:
anatofuz
parents:
diff changeset
20 n++;
anatofuz
parents:
diff changeset
21 break;
anatofuz
parents:
diff changeset
22 }
anatofuz
parents:
diff changeset
23 return n;
anatofuz
parents:
diff changeset
24 }