1 // RUN: %clang_cc1 %s -std=c++11 -fcxx-exceptions -fexceptions -fsyntax-only -Wignored-qualifiers -verify
8 template<typename T
> T
f() { }
20 // Don't warn on cv-qualified class return types, only scalar return types.
21 namespace ignored_quals
{
24 const volatile S
class_cv();
26 const int scalar_c(); // expected-warning{{'const' type qualifier on return type has no effect}}
27 int const scalar_c2(); // expected-warning{{'const' type qualifier on return type has no effect}}
31 const // expected-warning{{'const' type qualifier on return type has no effect}}
36 const // expected-warning{{'const' type qualifier on return type has no effect}}
39 char* const h(); // expected-warning{{'const' type qualifier on return type has no effect}}
40 char* volatile i(); // expected-warning{{'volatile' type qualifier on return type has no effect}}
43 volatile // expected-warning{{'const volatile' type qualifiers on return type have no effect}}
47 const volatile int scalar_cv(); // expected-warning{{'const volatile' type qualifiers on return type have no effect}}
49 // FIXME: Maintain enough information that we can point the diagnostic at the 'volatile' keyword.
53 mixed_ret(); // expected-warning {{'volatile' type qualifier on return type has no effect}}
55 const int volatile // expected-warning {{'const volatile' type qualifiers on return type have no effect}}
58 _Atomic(int) atomic();
60 _Atomic
// expected-warning {{'_Atomic' type qualifier on return type has no effect}}
64 auto trailing_return_type() ->
65 const int; // expected-warning {{'const' type qualifier on return type has no effect}}
67 auto trailing_return_type_lambda
= [](const int &x
) ->
68 const int // expected-warning {{'const' type qualifier on return type has no effect}}
71 const int ret_array()[4]; // expected-error {{cannot return array}}
78 const PCHAR
GetName() { return 0; } // expected-warning{{'const' type qualifier on return type has no effect}}
83 operator const int ();
84 operator int * const ();
92 template <class VarType
>
93 void Test(const VarType
& value
) {
98 namespace return_has_expr
{
101 return 42; // expected-error {{constructor 'S' should not return a value}}
104 return 42; // expected-error {{destructor '~S' should not return a value}}
111 namespace ctor_returns_void
{
114 S() { return f(); } // expected-error {{constructor 'S' must not return void expression}}
115 ~S() { return f(); } // expected-error {{destructor '~S' must not return void expression}}
118 template <typename T
> struct ST
{
119 ST() { return f(); } // expected-error {{constructor 'ST<T>' must not return void expression}}
120 // expected-error@-1 {{constructor 'ST' must not return void expression}}
121 ~ST() { return f(); } // expected-error {{destructor '~ST<T>' must not return void expression}}
122 // expected-error@-1 {{destructor '~ST' must not return void expression}}
125 ST
<int> st
; // expected-note {{in instantiation of member function 'ctor_returns_void::ST<int>::ST'}}
126 // expected-note@-1 {{in instantiation of member function 'ctor_returns_void::ST<int>::~ST'}}
129 void cxx_unresolved_expr() {
130 // The use of an undeclared variable tricks clang into building a
131 // CXXUnresolvedConstructExpr, and the missing ')' gives it an invalid source
132 // location for its rparen. Check that emitting a diag on the range of the
133 // expr doesn't assert.
134 return int(undeclared
, 4; // expected-error {{expected ')'}} expected-note{{to match this '('}} expected-error {{use of undeclared identifier 'undeclared'}}