1ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo// RUN: %clang_cc1 --std=c++1y -fsyntax-only -verify %s
2ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo// RUN: cp %s %t
3ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo// RUN: not %clang_cc1 --std=c++1y -x c++ -fixit %t -DFIXING
4ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo// RUN: %clang_cc1 --std=c++1y -x c++ %t -DFIXING
5ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo
6ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufotemplate<typename T>
7ef4579cda09b73e3d4d98af48201da25adc29326Larisse VoufoT pi = T(3.1415926535897932385); // expected-note {{template is declared here}}
8ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo
9ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufotemplate int pi<int>;
10ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo
11ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo#ifndef FIXING
128e6557e57e2b88fd3de8a87e53e30c774497f51dRichard Smithtemplate float pi<>; // expected-error {{too few template arguments for template 'pi'}}
13ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufotemplate double pi_var0; // expected-error {{explicit instantiation of 'pi_var0' does not refer to a function template, variable template, member function, member class, or static data member}}
14ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo#endif
15ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo
16ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo// Should recover as if definition
17ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufotemplate double pi_var = 5; // expected-error {{variable cannot be defined in an explicit instantiation; if this declaration is meant to be a variable definition, remove the 'template' keyword}}
18ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo#ifndef FIXING
19ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufotemplate<typename T>
20ef4579cda09b73e3d4d98af48201da25adc29326Larisse VoufoT pi0 = T(3.1415926535897932385); // expected-note {{previous definition is here}}
21ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo
22ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufotemplate int pi0 = 10; // expected-error {{variable cannot be defined in an explicit instantiation; if this declaration is meant to be a variable definition, remove the 'template' keyword}} \
234a91989b2dc901a4998fa5443aeba0276a8cfaa6Larisse Voufo                          expected-error{{redefinition of 'pi0' as different kind of symbol}}
24ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo#endif
25ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo
26ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufotemplate<typename T>
27651f13cea278ec967336033dd032faef0e9fc2ecStephen HinesT pi1 = T(3.1415926535897932385); // expected-note 0-2 {{here}}
28ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo
29ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo// Should recover as if specialization
30ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufotemplate float pi1<float> = 1.0;  // expected-error {{explicit template instantiation cannot have a definition; if this definition is meant to be an explicit specialization, add '<>' after the 'template' keyword}}
31ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo#ifndef FIXING
32ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufonamespace expected_global {
33651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  template<> double pi1<double> = 1.5;  // expected-error {{variable template specialization of 'pi1' must originally be declared in the global scope}}
34ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo  template int pi1<int> = 10;  // expected-error {{explicit template instantiation cannot have a definition; if this definition is meant to be an explicit specialization, add '<>' after the 'template' keyword}} \
35651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines                                  expected-error {{variable template specialization of 'pi1' must originally be declared in the global scope}}
36ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo}
37ef4579cda09b73e3d4d98af48201da25adc29326Larisse Voufo#endif
38