diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-07-01 06:08:20 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-07-01 06:08:20 +0000 |
| commit | 0bca59d6f7a2259b7eddefaeb19fcec8e60f37db (patch) | |
| tree | ff766cd198de9f5f1135f3f869d8541817fd7778 /clang | |
| parent | 69665e112b6271a891fc82ee06b8ac02372d8440 (diff) | |
| download | bcm5719-llvm-0bca59d6f7a2259b7eddefaeb19fcec8e60f37db.tar.gz bcm5719-llvm-0bca59d6f7a2259b7eddefaeb19fcec8e60f37db.zip | |
PR16502: Fix a dumb bug where we might look past the last initializer in an
InitListExpr.
llvm-svn: 185304
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 2 | ||||
| -rw-r--r-- | clang/test/SemaCXX/decl-init-ref.cpp | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index f59571a4865..18328553d38 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -5346,6 +5346,8 @@ static void performLifetimeExtension(Expr *Init, const ValueDecl *ExtendingD) { for (RecordDecl::field_iterator I = RD->field_begin(), E = RD->field_end(); I != E; ++I) { + if (Index >= ILE->getNumInits()) + break; if (I->isUnnamedBitfield()) continue; Expr *SubInit = ILE->getInit(Index); diff --git a/clang/test/SemaCXX/decl-init-ref.cpp b/clang/test/SemaCXX/decl-init-ref.cpp index 6802e0c52c5..2d0c9cb4ffb 100644 --- a/clang/test/SemaCXX/decl-init-ref.cpp +++ b/clang/test/SemaCXX/decl-init-ref.cpp @@ -30,3 +30,9 @@ PR6139 x = {{A()}}; // expected-error{{non-const lvalue reference to type 'A [1] struct PR6139b { A (&x)[1]; }; PR6139b y = {A()}; // expected-error{{non-const lvalue reference to type 'A [1]' cannot bind to a temporary of type 'A'}} + +namespace PR16502 { + struct A { int &&temporary; int x, y; }; + int f(); + const A &c = { 10, ++c.temporary }; +} |

