diff options
| author | Richard Trieu <rtrieu@google.com> | 2014-08-28 03:23:47 +0000 |
|---|---|---|
| committer | Richard Trieu <rtrieu@google.com> | 2014-08-28 03:23:47 +0000 |
| commit | 8d08a2770ed6ed5fb65b748f100bd8242c80132d (patch) | |
| tree | 363a70cd9e4cf9f0daf5fdc3e5066cb971ef5f0b /clang/test | |
| parent | 31328168bbf8086c5bb22983fb89783fc8de9067 (diff) | |
| download | bcm5719-llvm-8d08a2770ed6ed5fb65b748f100bd8242c80132d.tar.gz bcm5719-llvm-8d08a2770ed6ed5fb65b748f100bd8242c80132d.zip | |
During cross field uninitialized checking, when processing an assignment,
don't mark the field as initialized until the next initializer instead of
instantly. Since this checker is AST based, statements are processed in tree
order instead of following code flow. This can result in different warnings
from just reordering the code. Also changed to use one checker per constructor
instead of creating a new checker per field.
class T {
int x, y;
// Already warns
T(bool b) : x(!b ? (1 + y) : (y = 5)) {}
// New warning added here, previously (1 + y) comes after (y = 5) in the AST
// preventing the warning.
T(bool b) : x(b ? (y = 5) : (1 + y)) {}
};
llvm-svn: 216641
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/SemaCXX/uninitialized.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/uninitialized.cpp b/clang/test/SemaCXX/uninitialized.cpp index fa453cbb290..b0b4ef672db 100644 --- a/clang/test/SemaCXX/uninitialized.cpp +++ b/clang/test/SemaCXX/uninitialized.cpp @@ -823,6 +823,20 @@ namespace cross_field_warnings { int d = a + b + c; R() : a(c = 5), b(c), c(a) {} }; + + // FIXME: Use the CFG-based analysis to give a sometimes uninitialized + // warning on y. + struct T { + int x; + int y; + T(bool b) + : x(b ? (y = 5) : (1 + y)), // expected-warning{{field 'y' is uninitialized when used here}} + y(y + 1) {} + T(int b) + : x(!b ? (1 + y) : (y = 5)), // expected-warning{{field 'y' is uninitialized when used here}} + y(y + 1) {} + }; + } namespace base_class { |

