r185304 - PR16502: Fix a dumb bug where we might look past the last initializer in an
Richard Smith
richard-llvm at metafoo.co.uk
Sun Jun 30 23:08:20 PDT 2013
Author: rsmith
Date: Mon Jul 1 01:08:20 2013
New Revision: 185304
URL: http://llvm.org/viewvc/llvm-project?rev=185304&view=rev
Log:
PR16502: Fix a dumb bug where we might look past the last initializer in an
InitListExpr.
Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/SemaCXX/decl-init-ref.cpp
Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=185304&r1=185303&r2=185304&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Mon Jul 1 01:08:20 2013
@@ -5346,6 +5346,8 @@ static void performLifetimeExtension(Exp
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);
Modified: cfe/trunk/test/SemaCXX/decl-init-ref.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/decl-init-ref.cpp?rev=185304&r1=185303&r2=185304&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/decl-init-ref.cpp (original)
+++ cfe/trunk/test/SemaCXX/decl-init-ref.cpp Mon Jul 1 01:08:20 2013
@@ -30,3 +30,9 @@ PR6139 x = {{A()}}; // expected-error{{n
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 };
+}
More information about the cfe-commits
mailing list