xref: /llvm-project/clang/test/FixIt/fixit-const-var-init.cpp (revision b3faa1a87ac37e3825a67368dfb8dcfef95f4c53)
1*b3faa1a8Sv1nh1shungry // RUN: not %clang_cc1 -fdiagnostics-parseable-fixits -x c++ -std=c++14 %s 2>&1 | FileCheck %s
2*b3faa1a8Sv1nh1shungry 
3*b3faa1a8Sv1nh1shungry const int a; // expected-error {{default initialization of an object of const type}}
4*b3faa1a8Sv1nh1shungry // CHECK: fix-it:"{{.*}}":{3:12-3:12}:" = 0"
5*b3faa1a8Sv1nh1shungry 
6*b3faa1a8Sv1nh1shungry template <class, class> const int b; // expected-error {{default initialization of an object of const type}}
7*b3faa1a8Sv1nh1shungry // CHECK: fix-it:"{{.*}}":{6:36-6:36}:" = 0"
8*b3faa1a8Sv1nh1shungry 
9*b3faa1a8Sv1nh1shungry template <class T> const int b<int, T>; // expected-error {{default initialization of an object of const type}}
10*b3faa1a8Sv1nh1shungry // CHECK: fix-it:"{{.*}}":{9:39-9:39}:" = 0"
11*b3faa1a8Sv1nh1shungry 
12*b3faa1a8Sv1nh1shungry template <> const int b<int, float>; // expected-error {{default initialization of an object of const type}}
13*b3faa1a8Sv1nh1shungry // CHECK: fix-it:"{{.*}}":{12:36-12:36}:" = 0"
14*b3faa1a8Sv1nh1shungry 
15*b3faa1a8Sv1nh1shungry constexpr float c; // expected-error {{must be initialized by a constant expression}}
16*b3faa1a8Sv1nh1shungry // CHECK: fix-it:"{{.*}}":{15:18-15:18}:" = 0.0"
17*b3faa1a8Sv1nh1shungry 
18*b3faa1a8Sv1nh1shungry template <class, class> constexpr float d; // expected-error {{must be initialized by a constant expression}}
19*b3faa1a8Sv1nh1shungry // CHECK: fix-it:"{{.*}}":{18:42-18:42}:" = 0.0"
20*b3faa1a8Sv1nh1shungry 
21*b3faa1a8Sv1nh1shungry template <class T> constexpr float d<T, int>; // expected-error {{must be initialized by a constant expression}}
22*b3faa1a8Sv1nh1shungry // CHECK: fix-it:"{{.*}}":{21:45-21:45}:" = 0.0"
23*b3faa1a8Sv1nh1shungry 
24*b3faa1a8Sv1nh1shungry template <> constexpr float d<int, float>; // expected-error {{must be initialized by a constant expression}}
25*b3faa1a8Sv1nh1shungry // CHECK: fix-it:"{{.*}}":{24:42-24:42}:" = 0.0"
26*b3faa1a8Sv1nh1shungry 
27*b3faa1a8Sv1nh1shungry void (* const func)(int, int); // expected-error {{default initialization of an object of const type}}
28*b3faa1a8Sv1nh1shungry // CHECK: fix-it:"{{.*}}":{27:30-27:30}:" = nullptr"
29