summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX/return.cpp
blob: af7f50ce44b3e77c835d2b2f66c54df36b424958 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// RUN: %clang_cc1 %s -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}}

const volatile int scalar_cv(); // expected-warning{{'const volatile' type qualifiers on return type have no effect}}
}

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 int * const ();
};
OpenPOWER on IntegriCloud