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
135 lines
4.0 KiB
C++
135 lines
4.0 KiB
C++
// RUN: %clang_cc1 %s -std=c++11 -fcxx-exceptions -fexceptions -fsyntax-only -Wignored-qualifiers -verify
|
|
|
|
int test1() {
|
|
throw;
|
|
}
|
|
|
|
// PR5071
|
|
template<typename T> T f() { }
|
|
|
|
template<typename T>
|
|
void g(T t) {
|
|
return t * 2; // okay
|
|
}
|
|
|
|
template<typename T>
|
|
T h() {
|
|
return 17;
|
|
}
|
|
|
|
// Don't warn on cv-qualified class return types, only scalar return types.
|
|
namespace ignored_quals {
|
|
struct S {};
|
|
const S class_c();
|
|
const volatile S class_cv();
|
|
|
|
const int scalar_c(); // expected-warning{{'const' type qualifier on return type has no effect}}
|
|
int const scalar_c2(); // expected-warning{{'const' type qualifier on return type has no effect}}
|
|
|
|
const
|
|
char*
|
|
const // expected-warning{{'const' type qualifier on return type has no effect}}
|
|
f();
|
|
|
|
char
|
|
const*
|
|
const // expected-warning{{'const' type qualifier on return type has no effect}}
|
|
g();
|
|
|
|
char* const h(); // expected-warning{{'const' type qualifier on return type has no effect}}
|
|
char* volatile i(); // expected-warning{{'volatile' type qualifier on return type has no effect}}
|
|
|
|
char*
|
|
volatile // expected-warning{{'const volatile' type qualifiers on return type have no effect}}
|
|
const
|
|
j();
|
|
|
|
const volatile int scalar_cv(); // expected-warning{{'const volatile' type qualifiers on return type have no effect}}
|
|
|
|
// FIXME: Maintain enough information that we can point the diagnostic at the 'volatile' keyword.
|
|
const
|
|
int S::*
|
|
volatile
|
|
mixed_ret(); // expected-warning {{'volatile' type qualifier on return type has no effect}}
|
|
|
|
const int volatile // expected-warning {{'const volatile' type qualifiers on return type have no effect}}
|
|
(((parens())));
|
|
|
|
_Atomic(int) atomic();
|
|
|
|
_Atomic // expected-warning {{'_Atomic' type qualifier on return type has no effect}}
|
|
int
|
|
atomic();
|
|
|
|
auto trailing_return_type() ->
|
|
const int; // expected-warning {{'const' type qualifier on return type has no effect}}
|
|
|
|
auto trailing_return_type_lambda = [](const int &x) ->
|
|
const int // expected-warning {{'const' type qualifier on return type has no effect}}
|
|
{ return x; };
|
|
|
|
const int ret_array()[4]; // expected-error {{cannot return array}}
|
|
}
|
|
|
|
namespace PR9328 {
|
|
typedef char *PCHAR;
|
|
class Test
|
|
{
|
|
const PCHAR GetName() { return 0; } // expected-warning{{'const' type qualifier on return type has no effect}}
|
|
};
|
|
}
|
|
|
|
class foo {
|
|
operator const int ();
|
|
operator int * const ();
|
|
};
|
|
|
|
namespace PR10057 {
|
|
struct S {
|
|
~S();
|
|
};
|
|
|
|
template <class VarType>
|
|
void Test(const VarType& value) {
|
|
return S() = value;
|
|
}
|
|
}
|
|
|
|
namespace return_has_expr {
|
|
struct S {
|
|
S() {
|
|
return 42; // expected-error {{constructor 'S' should not return a value}}
|
|
}
|
|
~S() {
|
|
return 42; // expected-error {{destructor '~S' should not return a value}}
|
|
}
|
|
};
|
|
}
|
|
|
|
// pr17759
|
|
namespace ctor_returns_void {
|
|
void f() {}
|
|
struct S {
|
|
S() { return f(); } // expected-error {{constructor 'S' must not return void expression}}
|
|
~S() { return f(); } // expected-error {{destructor '~S' must not return void expression}}
|
|
};
|
|
|
|
template <typename T> struct ST {
|
|
ST() { return f(); } // expected-error {{constructor 'ST<T>' must not return void expression}}
|
|
// expected-error@-1 {{constructor 'ST' must not return void expression}}
|
|
~ST() { return f(); } // expected-error {{destructor '~ST<T>' must not return void expression}}
|
|
// expected-error@-1 {{destructor '~ST' must not return void expression}}
|
|
};
|
|
|
|
ST<int> st; // expected-note {{in instantiation of member function 'ctor_returns_void::ST<int>::ST'}}
|
|
// expected-note@-1 {{in instantiation of member function 'ctor_returns_void::ST<int>::~ST'}}
|
|
}
|
|
|
|
void cxx_unresolved_expr() {
|
|
// The use of an undeclared variable tricks clang into building a
|
|
// CXXUnresolvedConstructExpr, and the missing ')' gives it an invalid source
|
|
// location for its rparen. Check that emitting a diag on the range of the
|
|
// expr doesn't assert.
|
|
return int(undeclared, 4; // expected-error {{expected ')'}} expected-note{{to match this '('}} expected-error {{use of undeclared identifier 'undeclared'}}
|
|
}
|