1// RUN: %clang_cc1 %s -std=c++11 -fcxx-exceptions -fexceptions -fsyntax-only -Wignored-qualifiers -verify 2 3int test1() { 4 throw; 5} 6 7// PR5071 8template<typename T> T f() { } 9 10template<typename T> 11void g(T t) { 12 return t * 2; // okay 13} 14 15template<typename T> 16T h() { 17 return 17; 18} 19 20// Don't warn on cv-qualified class return types, only scalar return types. 21namespace ignored_quals { 22struct S {}; 23const S class_c(); 24const volatile S class_cv(); 25 26const int scalar_c(); // expected-warning{{'const' type qualifier on return type has no effect}} 27int const scalar_c2(); // expected-warning{{'const' type qualifier on return type has no effect}} 28 29const 30char* 31const // expected-warning{{'const' type qualifier on return type has no effect}} 32f(); 33 34char 35const* 36const // expected-warning{{'const' type qualifier on return type has no effect}} 37g(); 38 39char* const h(); // expected-warning{{'const' type qualifier on return type has no effect}} 40char* volatile i(); // expected-warning{{'volatile' type qualifier on return type has no effect}} 41 42char* 43volatile // expected-warning{{'const volatile' type qualifiers on return type have no effect}} 44const 45j(); 46 47const volatile int scalar_cv(); // expected-warning{{'const volatile' type qualifiers on return type have no effect}} 48 49// FIXME: Maintain enough information that we can point the diagnostic at the 'volatile' keyword. 50const 51int S::* 52volatile 53mixed_ret(); // expected-warning {{'volatile' type qualifier on return type has no effect}} 54 55const int volatile // expected-warning {{'const volatile' type qualifiers on return type have no effect}} 56 (((parens()))); 57 58_Atomic(int) atomic(); 59 60_Atomic // expected-warning {{'_Atomic' type qualifier on return type has no effect}} 61 int 62 atomic(); 63 64auto 65 trailing_return_type() -> // expected-warning {{'const' type qualifier on return type has no effect}} 66 const int; 67 68const int ret_array()[4]; // expected-error {{cannot return array}} 69} 70 71namespace PR9328 { 72 typedef char *PCHAR; 73 class Test 74 { 75 const PCHAR GetName() { return 0; } // expected-warning{{'const' type qualifier on return type has no effect}} 76 }; 77} 78 79class foo { 80 operator const int (); 81 operator int * const (); 82}; 83 84namespace PR10057 { 85 struct S { 86 ~S(); 87 }; 88 89 template <class VarType> 90 void Test(const VarType& value) { 91 return S() = value; 92 } 93} 94 95namespace return_has_expr { 96 struct S { 97 S() { 98 return 42; // expected-error {{constructor 'S' should not return a value}} 99 } 100 ~S() { 101 return 42; // expected-error {{destructor '~S' should not return a value}} 102 } 103 }; 104} 105 106// rdar://15366494 107// pr17759 108namespace ctor_returns_void { 109 void f() {} 110 struct S { 111 S() { return f(); }; // expected-error {{constructor 'S' must not return void expression}} 112 ~S() { return f(); } // expected-error {{destructor '~S' must not return void expression}} 113 }; 114} 115