CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
99 lines
3.7 KiB
C
99 lines
3.7 KiB
C
// RUN: %clang_cc1 -fsyntax-only -Wenum-compare-typo -verify %s
|
|
// RUN: %clang_cc1 -fsyntax-only -Wenum-compare-typo -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
|
|
|
|
|
|
enum PossibleTypoLeft {
|
|
Val1 = 1 << 0,
|
|
// expected-warning@+3 {{comparison operator '<' is potentially a typo for a shift operator '<<'}}
|
|
// expected-note@+2 {{use '<<' to perform a bitwise shift}}
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE+1]]:12-[[@LINE+1]]:13}:"<<"
|
|
Bad1 = 1 < 2,
|
|
// expected-warning@+3 {{comparison operator '>' is potentially a typo for a shift operator '>>'}}
|
|
// expected-note@+2 {{use '>>' to perform a bitwise shift}}
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE+1]]:12-[[@LINE+1]]:13}:">>"
|
|
Bad2 = 1 > 3,
|
|
// expected-warning@+3 {{comparison operator '>' is potentially a typo for a shift operator '>>'}}
|
|
// expected-note@+2 {{use '>>' to perform a bitwise shift}}
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE+1]]:13-[[@LINE+1]]:14}:">>"
|
|
Bad3 = (1 > 3)
|
|
};
|
|
|
|
enum PossibleTypoRight {
|
|
Val2 = 1 >> 0,
|
|
// expected-warning@+3 {{comparison operator '<' is potentially a typo for a shift operator '<<'}}
|
|
// expected-note@+2 {{use '<<' to perform a bitwise shift}}
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE+1]]:12-[[@LINE+1]]:13}:"<<"
|
|
Bad4 = 1 < 2,
|
|
// expected-warning@+3 {{comparison operator '>' is potentially a typo for a shift operator '>>'}}
|
|
// expected-note@+2 {{use '>>' to perform a bitwise shift}}
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE+1]]:12-[[@LINE+1]]:13}:">>"
|
|
Bad5 = 1 > 3,
|
|
// expected-warning@+3 {{comparison operator '<' is potentially a typo for a shift operator '<<'}}
|
|
// expected-note@+2 {{use '<<' to perform a bitwise shift}}
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE+1]]:13-[[@LINE+1]]:14}:"<<"
|
|
Bad6 = (1 < 3)
|
|
};
|
|
|
|
// Case 3: Context provided by other bitwise operators (&, |)
|
|
// Even though there are no shifts, the presence of '|' implies flags.
|
|
enum PossibleTypoBitwiseOr {
|
|
FlagA = 0x1,
|
|
FlagB = 0x2,
|
|
FlagCombo = FlagA | FlagB,
|
|
// expected-warning@+3 {{comparison operator '<' is potentially a typo for a shift operator '<<'}}
|
|
// expected-note@+2 {{use '<<' to perform a bitwise shift}}
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE+1]]:17-[[@LINE+1]]:18}:"<<"
|
|
FlagTypo1 = 1 < FlagCombo,
|
|
// expected-warning@+3 {{comparison operator '>' is potentially a typo for a shift operator '>>'}}
|
|
// expected-note@+2 {{use '>>' to perform a bitwise shift}}
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE+1]]:17-[[@LINE+1]]:18}:">>"
|
|
FlagTypo2 = 1 > FlagCombo
|
|
};
|
|
|
|
enum PossibleTypoBitwiseAnd {
|
|
FlagAnd = FlagA & FlagB,
|
|
// expected-warning@+3 {{comparison operator '<' is potentially a typo for a shift operator '<<'}}
|
|
// expected-note@+2 {{use '<<' to perform a bitwise shift}}
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE+1]]:17-[[@LINE+1]]:18}:"<<"
|
|
FlagTypo3 = 1 < FlagAnd,
|
|
// expected-warning@+3 {{comparison operator '>' is potentially a typo for a shift operator '>>'}}
|
|
// expected-note@+2 {{use '>>' to perform a bitwise shift}}
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE+1]]:17-[[@LINE+1]]:18}:">>"
|
|
FlagTypo4 = 1 > FlagAnd
|
|
};
|
|
|
|
enum NoWarningOnDirectInit {
|
|
A = 0,
|
|
B = 1,
|
|
Ok1 = 1 < 2, // No warning expected
|
|
Ok2 = 1 > 2 // No warning expected
|
|
};
|
|
|
|
enum NoWarningOnArith {
|
|
D = 0 + 1,
|
|
E = D * 10,
|
|
F = E - D,
|
|
G = F / D,
|
|
Ok3 = 1 < E, // No warning expected
|
|
Ok4 = 1 > E // No warning expected
|
|
};
|
|
|
|
enum NoWarningOnExplicitCast {
|
|
Bit1 = 1 << 0,
|
|
Ok5 = (int)(1 < 2) // No warning expected
|
|
};
|
|
|
|
enum NoWarningOnNoneBitShift {
|
|
Bit2 = 1 << 0,
|
|
Ok6 = (3 < 2) // No warning expected
|
|
};
|
|
|
|
// Ensure the diagnostic group works
|
|
#pragma clang diagnostic push
|
|
#pragma clang diagnostic ignored "-Wenum-compare-typo"
|
|
enum IGNORED {
|
|
Ok7 = 1 << 1,
|
|
Ignored3 = 1 < 10 // No warning
|
|
};
|
|
#pragma clang diagnostic pop
|