mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-18 09:06:43 +00:00

We have a new policy in place making links to private resources something we try to avoid in source and test files. Normally, we'd organically switch to the new policy rather than make a sweeping change across a project. However, Clang is in a somewhat special circumstance currently: recently, I've had several new contributors run into rdar links around test code which their patch was changing the behavior of. This turns out to be a surprisingly bad experience, especially for newer folks, for a handful of reasons: not understanding what the link is and feeling intimidated by it, wondering whether their changes are actually breaking something important to a downstream in some way, having to hunt down strangers not involved with the patch to impose on them for help, accidental pressure from asking for potentially private IP to be made public, etc. Because folks run into these links entirely by chance (through fixing bugs or working on new features), there's not really a set of problematic links to focus on -- all of the links have basically the same potential for causing these problems. As a result, this is an omnibus patch to remove all such links. This was not a mechanical change; it was done by manually searching for rdar, radar, radr, and other variants to find all the various problematic links. From there, I tried to retain or reword the surrounding comments so that we would lose as little context as possible. However, because most links were just a plain link with no supporting context, the majority of the changes are simple removals. Differential Review: https://reviews.llvm.org/D158071
148 lines
3.0 KiB
C++
148 lines
3.0 KiB
C++
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
|
|
|
|
void test() {
|
|
bool x = true;
|
|
switch (x) { // expected-warning {{bool}}
|
|
case 0:
|
|
break;
|
|
}
|
|
|
|
int n = 3;
|
|
switch (n && true) { // expected-warning {{bool}}
|
|
case 1:
|
|
break;
|
|
}
|
|
}
|
|
|
|
// PR5518
|
|
struct A {
|
|
operator int(); // expected-note{{conversion to integral type}}
|
|
};
|
|
|
|
void x() {
|
|
switch(A()) {
|
|
}
|
|
}
|
|
|
|
enum E { e1, e2 };
|
|
struct B : A {
|
|
operator E() const; // expected-note{{conversion to enumeration type}}
|
|
};
|
|
|
|
void x2() {
|
|
switch (B()) { // expected-error{{multiple conversions}}
|
|
}
|
|
}
|
|
|
|
struct C; // expected-note{{forward declaration}}
|
|
|
|
void x3(C &c) {
|
|
switch (c) { // expected-error{{incomplete class type}}
|
|
}
|
|
}
|
|
|
|
namespace test3 {
|
|
enum En { A, B, C };
|
|
template <En how> void foo() {
|
|
int x = 0, y = 5;
|
|
|
|
switch (how) { //expected-warning {{no case matching constant switch condition '2'}}
|
|
case A: x *= y; break;
|
|
case B: x += y; break;
|
|
// No case for C, but it's okay because we have a constant condition.
|
|
}
|
|
}
|
|
|
|
template void foo<A>();
|
|
template void foo<B>();
|
|
template void foo<C>(); //expected-note {{in instantiation}}
|
|
}
|
|
|
|
// PR9304
|
|
void click_check_header_sizes() {
|
|
switch (0 == 8) { // expected-warning {{switch condition has boolean value}}
|
|
case 0: ;
|
|
}
|
|
}
|
|
|
|
void local_class(int n) {
|
|
for (;;) switch (n) {
|
|
case 0:
|
|
struct S {
|
|
void f() {
|
|
case 1: // expected-error {{'case' statement not in switch statement}}
|
|
break; // expected-error {{'break' statement not in loop or switch statement}}
|
|
default: // expected-error {{'default' statement not in switch statement}}
|
|
continue; // expected-error {{'continue' statement not in loop statement}}
|
|
}
|
|
};
|
|
S().f();
|
|
[]{
|
|
case 2: // expected-error {{'case' statement not in switch statement}}
|
|
break; // expected-error {{'break' statement not in loop or switch statement}}
|
|
default: // expected-error {{'default' statement not in switch statement}}
|
|
continue; // expected-error {{'continue' statement not in loop statement}}
|
|
}();
|
|
}
|
|
}
|
|
|
|
namespace Conversion {
|
|
struct S {
|
|
explicit operator int(); // expected-note {{conversion}}
|
|
};
|
|
template<typename T> void f(T t) {
|
|
switch (t) { // expected-error {{explicit conversion}}
|
|
case 0:
|
|
return;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
template void f(S); // expected-note {{instantiation of}}
|
|
}
|
|
|
|
namespace OpaqueEnumWarnings {
|
|
|
|
enum Opaque : int;
|
|
enum class OpaqueClass : int;
|
|
|
|
enum class Defined : int;
|
|
enum class Defined : int { a };
|
|
|
|
void test(Opaque o, OpaqueClass oc, Defined d) {
|
|
// Don't warn that case value is not present in opaque enums.
|
|
switch (o) {
|
|
case (Opaque)1:
|
|
break;
|
|
}
|
|
switch (oc) {
|
|
case (OpaqueClass)1:
|
|
break;
|
|
}
|
|
|
|
switch (d) {
|
|
case Defined::a:
|
|
break;
|
|
case (Defined)2: // expected-warning {{case value not in enumerated type 'Defined'}}
|
|
break;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
namespace EmptyEnum {
|
|
|
|
enum Empty : int {};
|
|
void test(Empty e) {
|
|
switch (e) {
|
|
case (Empty)0:
|
|
break;
|
|
}
|
|
switch (e) {
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
} // namespace EmptyEnum
|