Douglas Gregor | f0f8369 | 2010-08-24 05:27:49 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 | struct InClassInitializerOnly { |
| 3 | static const int i = 0; |
| 4 | }; |
| 5 | int const InClassInitializerOnly::i; |
| 6 | |
| 7 | struct OutOfClassInitializerOnly { |
| 8 | static const int i; |
| 9 | }; |
| 10 | int const OutOfClassInitializerOnly::i = 0; |
| 11 | |
| 12 | struct InClassInitializerAndOutOfClassCopyInitializer { |
Hans Wennborg | 84fe12d | 2013-11-21 03:17:44 +0000 | [diff] [blame] | 13 | static const int i = 0; // expected-note{{previous initialization is here}} |
Douglas Gregor | f0f8369 | 2010-08-24 05:27:49 +0000 | [diff] [blame] | 14 | }; |
Hans Wennborg | 84fe12d | 2013-11-21 03:17:44 +0000 | [diff] [blame] | 15 | int const InClassInitializerAndOutOfClassCopyInitializer::i = 0; // expected-error{{static data member 'i' already has an initializer}} |
Douglas Gregor | f0f8369 | 2010-08-24 05:27:49 +0000 | [diff] [blame] | 16 | |
| 17 | struct InClassInitializerAndOutOfClassDirectInitializer { |
Hans Wennborg | 84fe12d | 2013-11-21 03:17:44 +0000 | [diff] [blame] | 18 | static const int i = 0; // expected-note{{previous initialization is here}} |
Douglas Gregor | f0f8369 | 2010-08-24 05:27:49 +0000 | [diff] [blame] | 19 | }; |
Hans Wennborg | 84fe12d | 2013-11-21 03:17:44 +0000 | [diff] [blame] | 20 | int const InClassInitializerAndOutOfClassDirectInitializer::i(0); // expected-error{{static data member 'i' already has an initializer}} |
Douglas Gregor | f0f8369 | 2010-08-24 05:27:49 +0000 | [diff] [blame] | 21 | |
| 22 | |
| 23 | int main() { } |
| 24 | |