mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 04:56:07 +00:00

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
14 lines
597 B
C
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:;
|
|
}
|
|
}
|