diff options
Diffstat (limited to 'clang/test/SemaCXX/uninitialized.cpp')
-rw-r--r-- | clang/test/SemaCXX/uninitialized.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/clang/test/SemaCXX/uninitialized.cpp b/clang/test/SemaCXX/uninitialized.cpp index 0633764c1b4..baee272ed58 100644 --- a/clang/test/SemaCXX/uninitialized.cpp +++ b/clang/test/SemaCXX/uninitialized.cpp @@ -379,6 +379,25 @@ namespace statics { } } +namespace in_class_initializers { + struct S { + S() : a(a + 1) {} // expected-warning{{field is uninitialized when used here}} + int a = 42; // Note: because a is in a member initializer list, this initialization is ignored. + }; + + struct T { + T() : b(a + 1) {} // No-warning. + int a = 42; + int b; + }; + + struct U { + U() : a(b + 1), b(a + 1) {} // FIXME: Warn here. + int a = 42; // Note: because a and b are in the member initializer list, these initializers are ignored. + int b = 1; + }; +} + namespace references { int &a = a; // expected-warning{{reference 'a' is not yet bound to a value when used within its own initialization}} @@ -394,6 +413,13 @@ namespace references { struct T { T() : a(b), b(a) {} // FIXME: Warn here. int &a, &b; - int &c = c; // FIXME: Warn here. + int &c = c; // expected-warning{{reference is not yet bound to a value when used here}} + }; + + int x; + struct U { + U() : b(a) {} // No-warning. + int &a = x; + int &b; }; } |