summaryrefslogtreecommitdiff
path: root/clang/test/SemaCXX
diff options
context:
space:
mode:
authorNicolas Lesser <blitzrakete@gmail.com>2018-07-12 17:43:49 +0000
committerNicolas Lesser <blitzrakete@gmail.com>2018-07-12 17:43:49 +0000
commit294b383e6b0511bb3df1880c09d0ab1b9c49a6d0 (patch)
tree93fcad0566d0a6a9584abd8a451a75aaf85a73fe /clang/test/SemaCXX
parenta96175a6ce83a7dd6ddb52798eb86ef95e271e4b (diff)
[C++11] Fix warning when dropping cv-qualifiers when assigning to a reference with a braced initializer list
Diffstat (limited to 'clang/test/SemaCXX')
-rw-r--r--clang/test/SemaCXX/references.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/references.cpp b/clang/test/SemaCXX/references.cpp
index b34b740bd44..e32f4a8b0b0 100644
--- a/clang/test/SemaCXX/references.cpp
+++ b/clang/test/SemaCXX/references.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
int g(int);
void f() {
@@ -55,6 +56,24 @@ void test5() {
// const double& rcd2 = 2; // rcd2 refers to temporary with value 2.0
const volatile int cvi = 1;
const int& r = cvi; // expected-error{{binding value of type 'const volatile int' to reference to type 'const int' drops 'volatile' qualifier}}
+
+#if __cplusplus >= 201103L
+ const int& r2{cvi}; // expected-error{{binding value of type 'const volatile int' to reference to type 'const int' drops 'volatile' qualifier}}
+
+ const int a = 2;
+ int& r3{a}; // expected-error{{binding value of type 'const int' to reference to type 'int' drops 'const'}}
+
+ const int&& r4{a}; // expected-error{{rvalue reference to type 'const int' cannot bind to lvalue of type 'const int'}}
+
+ void func();
+ void func(int);
+ int &ptr1 = {func}; // expected-error{{address of overloaded function 'func' does not match required type 'int'}}
+ int &&ptr2{func}; // expected-error{{address of overloaded function 'func' does not match required type 'int'}}
+ // expected-note@-4{{candidate function}}
+ // expected-note@-4{{candidate function}}
+ // expected-note@-6{{candidate function}}
+ // expected-note@-6{{candidate function}}
+#endif
}
// C++ [dcl.init.ref]p3