aboutsummaryrefslogtreecommitdiff
path: root/test/FixIt/fixit-cxx0x.cpp
blob: d9b8763b056c3dd6b7ba15ce2c3bf74c313bf438 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// RUN: %clang_cc1 -verify -std=c++11 %s
// RUN: cp %s %t
// RUN: not %clang_cc1 -x c++ -std=c++11 -fixit %t
// RUN: %clang_cc1 -Wall -pedantic -x c++ -std=c++11 %t

/* This is a test of the various code modification hints that only
   apply in C++0x. */
struct A {
  explicit operator int(); // expected-note{{conversion to integral type}}
};

void x() {
  switch(A()) { // expected-error{{explicit conversion to}}
  }
}

using ::T = void; // expected-error {{name defined in alias declaration must be an identifier}}
using typename U = void; // expected-error {{name defined in alias declaration must be an identifier}}
using typename ::V = void; // expected-error {{name defined in alias declaration must be an identifier}}

namespace Constexpr {
  extern constexpr int a; // expected-error {{must be a definition}}
  // -> extern const int a;

  extern constexpr int *b; // expected-error {{must be a definition}}
  // -> extern int *const b;

  extern constexpr int &c; // expected-error {{must be a definition}}
  // -> extern int &b;

  extern constexpr const int d; // expected-error {{must be a definition}}
  // -> extern const int d;

  int z;
  constexpr int a = 0;
  constexpr int *b = &z;
  constexpr int &c = z;
  constexpr int d = a;

  // FIXME: Provide FixIts for static data members too.
#if 0
  struct S {
    static constexpr int b; // xpected-error {{requires an initializer}}
    // -> const int b;
  };

  constexpr int S::b = 0;
#endif

  struct S {
    static char *const p = 0; // expected-error {{requires 'constexpr' specifier}}
    // -> constexpr static char *const p = 0;
  };
}

namespace SemiCommaTypo {
  int m {},
  n [[]], // expected-error {{expected ';' at end of declaration}}
  int o;
}

int extraSemi(); // expected-error {{stray ';' in function definition}}
  = delete;

class ExtraSemi {
public:
  ExtraSemi();
  ExtraSemi(const ExtraSemi &);
  int n;
};
ExtraSemi::ExtraSemi(); // expected-error {{stray ';'}}
 : n(0) {
}
ExtraSemi::ExtraSemi(const ExtraSemi &); // expected-error {{stray ';'}}
  = default;

template<typename T> T extraSemi(T t);

template<typename T> T extraSemi(T t); // expected-error {{stray ';'}}
{
  return t;
}
template int extraSemi(int);