davide removed rL LLVM as the repository for this revision.
davide updated this revision to Diff 29640.
davide added a comment.
Testcase.
http://reviews.llvm.org/D10881
Files:
lib/Sema/SemaInit.cpp
test/SemaCXX/bind-infinite-recursion.cpp
Index: test/SemaCXX/bind-infinite-recursion.cpp
===================================================================
--- test/SemaCXX/bind-infinite-recursion.cpp
+++ test/SemaCXX/bind-infinite-recursion.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+struct S;
+
+struct W {
+ W( const S& ) {} // expected-note {{passing argument to parameter here}}
+};
+
+struct S {
+ S(volatile W) {}
+};
+
+int main() {
+ volatile W *w = 0;
+ S s(*w); // expected-error {{binding value of type 'volatile W' to
reference to type 'const S' drops 'volatile' qualifier}}
+ return 0;
+}
+
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:
Index: test/SemaCXX/bind-infinite-recursion.cpp
===================================================================
--- test/SemaCXX/bind-infinite-recursion.cpp
+++ test/SemaCXX/bind-infinite-recursion.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+struct S;
+
+struct W {
+ W( const S& ) {} // expected-note {{passing argument to parameter here}}
+};
+
+struct S {
+ S(volatile W) {}
+};
+
+int main() {
+ volatile W *w = 0;
+ S s(*w); // expected-error {{binding value of type 'volatile W' to reference to type 'const S' drops 'volatile' qualifier}}
+ return 0;
+}
+
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
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits