• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 %s -fcxx-exceptions -fexceptions -fsyntax-only -Wignored-qualifiers -verify
2 
test1()3 int test1() {
4   throw;
5 }
6 
7 // PR5071
f()8 template<typename T> T f() { }
9 
10 template<typename T>
g(T t)11 void g(T t) {
12   return t * 2; // okay
13 }
14 
15 template<typename T>
h()16 T h() {
17   return 17;
18 }
19 
20 // Don't warn on cv-qualified class return types, only scalar return types.
21 namespace ignored_quals {
22 struct S {};
23 const S class_c();
24 const volatile S class_cv();
25 
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}}
28 
29 const
30 char*
31 const // expected-warning{{'const' type qualifier on return type has no effect}}
32 f();
33 
34 char
35 const*
36 const // expected-warning{{'const' type qualifier on return type has no effect}}
37 g();
38 
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}}
41 
42 char*
43 volatile // expected-warning{{'const volatile' type qualifiers on return type have no effect}}
44 const
45 j();
46 
47 const volatile int scalar_cv(); // expected-warning{{'const volatile' type qualifiers on return type have no effect}}
48 }
49 
50 namespace PR9328 {
51   typedef char *PCHAR;
52   class Test
53   {
GetName()54     const PCHAR GetName() { return 0; } // expected-warning{{'const' type qualifier on return type has no effect}}
55   };
56 }
57 
58 class foo  {
59   operator int * const ();
60 };
61 
62 namespace PR10057 {
63   struct S {
64     ~S();
65   };
66 
67   template <class VarType>
Test(const VarType & value)68   void Test(const VarType& value) {
69     return S() = value;
70   }
71 }
72 
73 namespace return_has_expr {
74   struct S {
Sreturn_has_expr::S75     S() {
76       return 42; // expected-error {{constructor 'S' should not return a value}}
77     }
~Sreturn_has_expr::S78     ~S() {
79       return 42; // expected-error {{destructor '~S' should not return a value}}
80     }
81   };
82 }
83