<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, May 15, 2015 at 3:07 PM, Richard Trieu <span dir="ltr"><<a href="mailto:rtrieu@google.com" target="_blank">rtrieu@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rtrieu<br>
Date: Fri May 15 17:07:49 2015<br>
New Revision: 237482<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=237482&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=237482&view=rev</a><br>
Log:<br>
Reverse the order of types in the reference dropping qualifiers error.<br>
<br>
The error has the form ... 'int' ... 'const int' ... dropped qualifiers. At<br>
first glance, it appears that the const qualifier is added. Reverse the types<br>
so that the second type is less qualified than the first.<br>
<br>
Modified:<br>
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>
cfe/trunk/lib/Sema/SemaInit.cpp<br>
cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp<br>
cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp<br>
cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp<br>
cfe/trunk/test/Misc/diag-template-diffing.cpp<br>
cfe/trunk/test/SemaCXX/builtins-arm.cpp<br>
cfe/trunk/test/SemaCXX/references.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=237482&r1=237481&r2=237482&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=237482&r1=237481&r2=237482&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)<br>
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri May 15 17:07:49 2015<br>
@@ -1490,8 +1490,8 @@ def err_lvalue_reference_bind_to_unrelat<br>
"%diff{to type $ cannot bind to a value of unrelated type $|"<br>
"cannot bind to a value of unrelated type}1,2">;<br>
def err_reference_bind_drops_quals : Error<<br>
- "binding of reference %diff{to type $ to a value of type $ drops qualifiers|"<br>
- "drops qualifiers}0,1">;<br>
+ "binding value %diff{of type $ to reference of type $ drops qualifiers|"<br></blockquote><div><br></div><div>This should be "to reference to type", not "to reference of type", because the following type is not a reference type.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ "to reference drops qualifiers}0,1">;<br>
def err_reference_bind_failed : Error<<br>
"reference %diff{to type $ could not bind to an %select{rvalue|lvalue}1 of "<br>
"type $|could not bind to %select{rvalue|lvalue}1 of incompatible type}0,2">;<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaInit.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=237482&r1=237481&r2=237482&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=237482&r1=237481&r2=237482&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaInit.cpp Fri May 15 17:07:49 2015<br>
@@ -6854,8 +6854,8 @@ bool InitializationSequence::Diagnose(Se<br>
<br>
case FK_ReferenceInitDropsQualifiers:<br>
S.Diag(Kind.getLocation(), diag::err_reference_bind_drops_quals)<br>
- << DestType.getNonReferenceType()<br>
<< Args[0]->getType()<br>
+ << DestType.getNonReferenceType()<br>
<< Args[0]->getSourceRange();<br>
break;<br>
<br>
<br>
Modified: cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp?rev=237482&r1=237481&r2=237482&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp?rev=237482&r1=237481&r2=237482&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp (original)<br>
+++ cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp Fri May 15 17:07:49 2015<br>
@@ -123,7 +123,7 @@ namespace std_example_2 {<br>
const double& rcd2 = 2;<br>
double&& rrd = 2;<br>
const volatile int cvi = 1;<br>
- const int& r2 = cvi; // expected-error{{binding of reference to type 'const int' to a value of type 'const volatile int' drops qualifiers}}<br>
+ const int& r2 = cvi; // expected-error{{binding value of type 'const volatile int' to reference of type 'const int' drops qualifiers}}<br>
<br>
double d;<br>
double&& rrd2 = d; // expected-error{{rvalue reference to type 'double' cannot bind to lvalue of type 'double'}}<br>
<br>
Modified: cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp?rev=237482&r1=237481&r2=237482&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp?rev=237482&r1=237481&r2=237482&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp (original)<br>
+++ cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp Fri May 15 17:07:49 2015<br>
@@ -64,10 +64,10 @@ void bind_lvalue_quals(volatile Base b,<br>
volatile const int ivc) {<br>
volatile Base &bvr1 = b;<br>
volatile Base &bvr2 = d;<br>
- volatile Base &bvr3 = bvc; // expected-error{{binding of reference to type 'volatile Base' to a value of type 'const volatile Base' drops qualifiers}}<br>
- volatile Base &bvr4 = dvc; // expected-error{{binding of reference to type 'volatile Base' to a value of type 'const volatile Derived' drops qualifiers}}<br>
+ volatile Base &bvr3 = bvc; // expected-error{{binding value of type 'const volatile Base' to reference of type 'volatile Base' drops qualifiers}}<br>
+ volatile Base &bvr4 = dvc; // expected-error{{binding value of type 'const volatile Derived' to reference of type 'volatile Base' drops qualifiers}}<br>
<br>
- volatile int &ir = ivc; // expected-error{{binding of reference to type 'volatile int' to a value of type 'const volatile int' drops qualifiers}}<br>
+ volatile int &ir = ivc; // expected-error{{binding value of type 'const volatile int' to reference of type 'volatile int' drops qualifiers}}<br>
<br>
const volatile Base &bcvr1 = b;<br>
const volatile Base &bcvr2 = d;<br>
@@ -118,8 +118,8 @@ void bind_const_lvalue_to_rvalue() {<br>
const Base &br3 = create<const Base>();<br>
const Base &br4 = create<const Derived>();<br>
<br>
- const Base &br5 = create<const volatile Base>(); // expected-error{{binding of reference to type 'const Base' to a value of type 'const volatile Base' drops qualifiers}}<br>
- const Base &br6 = create<const volatile Derived>(); // expected-error{{binding of reference to type 'const Base' to a value of type 'const volatile Derived' drops qualifiers}}<br>
+ const Base &br5 = create<const volatile Base>(); // expected-error{{binding value of type 'const volatile Base' to reference of type 'const Base' drops qualifiers}}<br>
+ const Base &br6 = create<const volatile Derived>(); // expected-error{{binding value of type 'const volatile Derived' to reference of type 'const Base' drops qualifiers}}<br>
<br>
const int &ir = create<int>();<br>
}<br>
<br>
Modified: cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp?rev=237482&r1=237481&r2=237482&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp?rev=237482&r1=237481&r2=237482&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp (original)<br>
+++ cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp Fri May 15 17:07:49 2015<br>
@@ -24,16 +24,16 @@ void test_capture(X x) {<br>
int a;<br>
[=]{<br>
[&] {<br>
- int &x = a; // expected-error{{binding of reference to type 'int' to a value of type 'const int' drops qualifiers}}<br>
- int &x2 = a; // expected-error{{binding of reference to type 'int' to a value of type 'const int' drops qualifiers}}<br>
+ int &x = a; // expected-error{{binding value of type 'const int' to reference of type 'int' drops qualifiers}}<br>
+ int &x2 = a; // expected-error{{binding value of type 'const int' to reference of type 'int' drops qualifiers}}<br>
}();<br>
}();<br>
<br>
[=]{<br>
[&a] {<br>
[&] {<br>
- int &x = a; // expected-error{{binding of reference to type 'int' to a value of type 'const int' drops qualifiers}}<br>
- int &x2 = a; // expected-error{{binding of reference to type 'int' to a value of type 'const int' drops qualifiers}}<br>
+ int &x = a; // expected-error{{binding value of type 'const int' to reference of type 'int' drops qualifiers}}<br>
+ int &x2 = a; // expected-error{{binding value of type 'const int' to reference of type 'int' drops qualifiers}}<br>
}();<br>
}();<br>
}();<br>
<br>
Modified: cfe/trunk/test/Misc/diag-template-diffing.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/diag-template-diffing.cpp?rev=237482&r1=237481&r2=237482&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/diag-template-diffing.cpp?rev=237482&r1=237481&r2=237482&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Misc/diag-template-diffing.cpp (original)<br>
+++ cfe/trunk/test/Misc/diag-template-diffing.cpp Fri May 15 17:07:49 2015<br>
@@ -1258,7 +1258,7 @@ using T = condition<(is_const())>;<br>
void foo(const T &t) {<br>
T &t2 = t;<br>
}<br>
-// CHECK-ELIDE-NOTREE: binding of reference to type 'condition<[...]>' to a value of type 'const condition<[...]>' drops qualifiers<br>
+// CHECK-ELIDE-NOTREE: binding value of type 'const condition<[...]>' to reference of type 'condition<[...]>' drops qualifiers<br>
}<br>
<br>
namespace BoolArgumentBitExtended {<br>
<br>
Modified: cfe/trunk/test/SemaCXX/builtins-arm.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/builtins-arm.cpp?rev=237482&r1=237481&r2=237482&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/builtins-arm.cpp?rev=237482&r1=237481&r2=237482&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaCXX/builtins-arm.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/builtins-arm.cpp Fri May 15 17:07:49 2015<br>
@@ -2,5 +2,5 @@<br>
<br>
// va_list on ARM AAPCS is struct { void* __ap }.<br>
int test1(const __builtin_va_list &ap) {<br>
- 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}}<br>
+ 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}}<br>
}<br>
<br>
Modified: cfe/trunk/test/SemaCXX/references.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/references.cpp?rev=237482&r1=237481&r2=237482&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/references.cpp?rev=237482&r1=237481&r2=237482&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaCXX/references.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/references.cpp Fri May 15 17:07:49 2015<br>
@@ -54,7 +54,7 @@ void test4() {<br>
void test5() {<br>
// const double& rcd2 = 2; // rcd2 refers to temporary with value 2.0<br>
const volatile int cvi = 1;<br>
- const int& r = cvi; // expected-error{{binding of reference to type 'const int' to a value of type 'const volatile int' drops qualifiers}}<br>
+ const int& r = cvi; // expected-error{{binding value of type 'const volatile int' to reference of type 'const int' drops qualifiers}}<br>
}<br>
<br>
// C++ [dcl.init.ref]p3<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>