llvm-project/clang/test/Sema/warn-unreachable-fallthrough.c
Takuya Shimizu de401ac2a4 [clang][Sema] Avoid duplicate diagnostics for unreachable fallthrough attribute
This patch checks whether -Wunreachable-code-fallthrough is enabled
when clang encounters unreachable fallthrough attributes and, if so,
suppresses code will never be executed warning to avoid duplicate
warnings.

Fixes https://github.com/llvm/llvm-project/issues/60416
Differential Revision: https://reviews.llvm.org/D145842
2023-03-14 08:43:35 -04:00

14 lines
597 B
C

// RUN: %clang_cc1 -fsyntax-only -verify -std=c2x -Wunreachable-code-fallthrough %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c2x -Wunreachable-code %s
// RUN: %clang_cc1 -fsyntax-only -verify=code -std=c2x -Wunreachable-code -Wno-unreachable-code-fallthrough %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c2x -Wno-unreachable-code -Wunreachable-code-fallthrough %s
int n;
void f(void){
switch (n){
[[fallthrough]]; // expected-warning{{fallthrough annotation in unreachable code}}
// code-warning@-1{{never be executed}}
case 1:;
}
}