From: Richard Trieu Date: Fri, 15 May 2015 22:07:49 +0000 (+0000) Subject: Reverse the order of types in the reference dropping qualifiers error. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9d6c94a79f96beb1681b51616af8356748638184;p=clang Reverse the order of types in the reference dropping qualifiers error. The error has the form ... 'int' ... 'const int' ... dropped qualifiers. At first glance, it appears that the const qualifier is added. Reverse the types so that the second type is less qualified than the first. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@237482 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 95e8f15c21..bc52d61d55 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -1490,8 +1490,8 @@ def err_lvalue_reference_bind_to_unrelated : Error< "%diff{to type $ cannot bind to a value of unrelated type $|" "cannot bind to a value of unrelated type}1,2">; def err_reference_bind_drops_quals : Error< - "binding of reference %diff{to type $ to a value of type $ drops qualifiers|" - "drops qualifiers}0,1">; + "binding value %diff{of type $ to reference of type $ drops qualifiers|" + "to reference drops qualifiers}0,1">; def err_reference_bind_failed : Error< "reference %diff{to type $ could not bind to an %select{rvalue|lvalue}1 of " "type $|could not bind to %select{rvalue|lvalue}1 of incompatible type}0,2">; diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index ac0688643c..32570c7175 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -6854,8 +6854,8 @@ bool InitializationSequence::Diagnose(Sema &S, case FK_ReferenceInitDropsQualifiers: S.Diag(Kind.getLocation(), diag::err_reference_bind_drops_quals) - << DestType.getNonReferenceType() << Args[0]->getType() + << DestType.getNonReferenceType() << Args[0]->getSourceRange(); break; diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp index fdfa6781fe..b872281b05 100644 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp @@ -123,7 +123,7 @@ namespace std_example_2 { const double& rcd2 = 2; double&& rrd = 2; const volatile int cvi = 1; - const int& r2 = cvi; // expected-error{{binding of reference to type 'const int' to a value of type 'const volatile int' drops qualifiers}} + const int& r2 = cvi; // expected-error{{binding value of type 'const volatile int' to reference of type 'const int' drops qualifiers}} double d; double&& rrd2 = d; // expected-error{{rvalue reference to type 'double' cannot bind to lvalue of type 'double'}} diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp index fee5f96c38..36fcf90425 100644 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp @@ -64,10 +64,10 @@ void bind_lvalue_quals(volatile Base b, volatile Derived d, volatile const int ivc) { volatile Base &bvr1 = b; volatile Base &bvr2 = d; - volatile Base &bvr3 = bvc; // expected-error{{binding of reference to type 'volatile Base' to a value of type 'const volatile Base' drops qualifiers}} - volatile Base &bvr4 = dvc; // expected-error{{binding of reference to type 'volatile Base' to a value of type 'const volatile Derived' drops qualifiers}} + volatile Base &bvr3 = bvc; // expected-error{{binding value of type 'const volatile Base' to reference of type 'volatile Base' drops qualifiers}} + volatile Base &bvr4 = dvc; // expected-error{{binding value of type 'const volatile Derived' to reference of type 'volatile Base' drops qualifiers}} - volatile int &ir = ivc; // expected-error{{binding of reference to type 'volatile int' to a value of type 'const volatile int' drops qualifiers}} + volatile int &ir = ivc; // expected-error{{binding value of type 'const volatile int' to reference of type 'volatile int' drops qualifiers}} const volatile Base &bcvr1 = b; const volatile Base &bcvr2 = d; @@ -118,8 +118,8 @@ void bind_const_lvalue_to_rvalue() { const Base &br3 = create(); const Base &br4 = create(); - const Base &br5 = create(); // expected-error{{binding of reference to type 'const Base' to a value of type 'const volatile Base' drops qualifiers}} - const Base &br6 = create(); // expected-error{{binding of reference to type 'const Base' to a value of type 'const volatile Derived' drops qualifiers}} + const Base &br5 = create(); // expected-error{{binding value of type 'const volatile Base' to reference of type 'const Base' drops qualifiers}} + const Base &br6 = create(); // expected-error{{binding value of type 'const volatile Derived' to reference of type 'const Base' drops qualifiers}} const int &ir = create(); } diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp index 0cf01ade43..0cbffe844e 100644 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp +++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp @@ -24,16 +24,16 @@ void test_capture(X x) { int a; [=]{ [&] { - int &x = a; // expected-error{{binding of reference to type 'int' to a value of type 'const int' drops qualifiers}} - int &x2 = a; // expected-error{{binding of reference to type 'int' to a value of type 'const int' drops qualifiers}} + int &x = a; // expected-error{{binding value of type 'const int' to reference of type 'int' drops qualifiers}} + int &x2 = a; // expected-error{{binding value of type 'const int' to reference of type 'int' drops qualifiers}} }(); }(); [=]{ [&a] { [&] { - int &x = a; // expected-error{{binding of reference to type 'int' to a value of type 'const int' drops qualifiers}} - int &x2 = a; // expected-error{{binding of reference to type 'int' to a value of type 'const int' drops qualifiers}} + int &x = a; // expected-error{{binding value of type 'const int' to reference of type 'int' drops qualifiers}} + int &x2 = a; // expected-error{{binding value of type 'const int' to reference of type 'int' drops qualifiers}} }(); }(); }(); diff --git a/test/Misc/diag-template-diffing.cpp b/test/Misc/diag-template-diffing.cpp index 0f2edfb635..367de4b8a7 100644 --- a/test/Misc/diag-template-diffing.cpp +++ b/test/Misc/diag-template-diffing.cpp @@ -1258,7 +1258,7 @@ using T = condition<(is_const())>; void foo(const T &t) { T &t2 = t; } -// CHECK-ELIDE-NOTREE: binding of reference to type 'condition<[...]>' to a value of type 'const condition<[...]>' drops qualifiers +// CHECK-ELIDE-NOTREE: binding value of type 'const condition<[...]>' to reference of type 'condition<[...]>' drops qualifiers } namespace BoolArgumentBitExtended { diff --git a/test/SemaCXX/builtins-arm.cpp b/test/SemaCXX/builtins-arm.cpp index 8a0cf8102b..683317dbbe 100644 --- a/test/SemaCXX/builtins-arm.cpp +++ b/test/SemaCXX/builtins-arm.cpp @@ -2,5 +2,5 @@ // va_list on ARM AAPCS is struct { void* __ap }. int test1(const __builtin_va_list &ap) { - return __builtin_va_arg(ap, int); // expected-error {{binding of reference to type '__builtin_va_list' to a value of type 'const __builtin_va_list' drops qualifiers}} + return __builtin_va_arg(ap, int); // expected-error {{binding value of type 'const __builtin_va_list' to reference of type '__builtin_va_list' drops qualifiers}} } diff --git a/test/SemaCXX/references.cpp b/test/SemaCXX/references.cpp index b1768b1a3a..64d87bd132 100644 --- a/test/SemaCXX/references.cpp +++ b/test/SemaCXX/references.cpp @@ -54,7 +54,7 @@ void test4() { 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 of reference to type 'const int' to a value of type 'const volatile int' drops qualifiers}} + const int& r = cvi; // expected-error{{binding value of type 'const volatile int' to reference of type 'const int' drops qualifiers}} } // C++ [dcl.init.ref]p3