Hi rsmith, rjmccall, This is an attempt to fix https://llvm.org/bugs/show_bug.cgi?id=23882 Sema doesn't diagnose that binding 'volatile W' to to reference of type 'const W&' will discard qualifier and we end up in an infinite loop later on (until we run out of stack).
InitSequence::Perform() -> ... -> GatherArgumentsForCall() -> InitSequence::Perform() I'm not sure if the check is OK as is, or needs to be generalized and/or moved. I'll add the testcase in the PR if this review is accepted. Thanks, -- Davide REPOSITORY rL LLVM http://reviews.llvm.org/D10881 Files: lib/Sema/SemaInit.cpp Index: lib/Sema/SemaInit.cpp =================================================================== --- lib/Sema/SemaInit.cpp +++ lib/Sema/SemaInit.cpp @@ -4087,6 +4087,12 @@ = S.CompareReferenceRelationship(DeclLoc, cv1T1, cv2T2, DerivedToBase, ObjCConversion, ObjCLifetimeConversion); + + if (isLValueRef && (!T1Quals.hasVolatile() && T2Quals.hasVolatile())) { + Sequence.SetFailed(InitializationSequence::FK_ReferenceInitDropsQualifiers); + return; + } + // C++0x [dcl.init.ref]p5: // A reference to type "cv1 T1" is initialized by an expression of type // "cv2 T2" as follows: EMAIL PREFERENCES http://reviews.llvm.org/settings/panel/emailpreferences/
Index: lib/Sema/SemaInit.cpp =================================================================== --- lib/Sema/SemaInit.cpp +++ lib/Sema/SemaInit.cpp @@ -4087,6 +4087,12 @@ = S.CompareReferenceRelationship(DeclLoc, cv1T1, cv2T2, DerivedToBase, ObjCConversion, ObjCLifetimeConversion); + + if (isLValueRef && (!T1Quals.hasVolatile() && T2Quals.hasVolatile())) { + Sequence.SetFailed(InitializationSequence::FK_ReferenceInitDropsQualifiers); + return; + } + // C++0x [dcl.init.ref]p5: // A reference to type "cv1 T1" is initialized by an expression of type // "cv2 T2" as follows:
_______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits