]> granicus.if.org Git - clang/commitdiff
Reverse the order of types in the reference dropping qualifiers error.
authorRichard Trieu <rtrieu@google.com>
Fri, 15 May 2015 22:07:49 +0000 (22:07 +0000)
committerRichard Trieu <rtrieu@google.com>
Fri, 15 May 2015 22:07:49 +0000 (22:07 +0000)
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

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaInit.cpp
test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp
test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp
test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp
test/Misc/diag-template-diffing.cpp
test/SemaCXX/builtins-arm.cpp
test/SemaCXX/references.cpp

index 95e8f15c21fc9ab774ac7a1a0577d8bf90ed02ce..bc52d61d55c7d798a3c87cb1b545435ad6e7a877 100644 (file)
@@ -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">;
index ac0688643c550940515fbdecac695ed3074c532f..32570c7175711f2ab875c3539d5b3188f561ac72 100644 (file)
@@ -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;
 
index fdfa6781fe27474865e5a7eb49b869a72d04b084..b872281b05a517b75b48e03651194e7ff3f5ac9b 100644 (file)
@@ -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'}}
index fee5f96c389f36cdc7e78cf583e298c027ec138f..36fcf904257606d2aed2946ce749b64cf461dbd3 100644 (file)
@@ -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>();
   const Base &br4 = create<const Derived>();
 
-  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}}
-  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}}
+  const Base &br5 = create<const volatile Base>(); // expected-error{{binding value of type 'const volatile Base' to reference of type 'const Base' drops qualifiers}}
+  const Base &br6 = create<const volatile Derived>(); // expected-error{{binding value of type 'const volatile Derived' to reference of type 'const Base' drops qualifiers}}
 
   const int &ir = create<int>();
 }
index 0cf01ade4313b7801cc8927368c070bc631eaf10..0cbffe844e761038f971fd3f0da327a37a538af8 100644 (file)
@@ -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}}
       }();
     }(); 
   }(); 
index 0f2edfb635466baba84e512f2f9946dd01bc7b02..367de4b8a7416661d674c71b0128018a21e0624f 100644 (file)
@@ -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 {
index 8a0cf8102b35e996f194eda25e4cf69828807fcf..683317dbbe65ad54217802092c44aeba2e5c27b6 100644 (file)
@@ -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}}
 }
index b1768b1a3a4d80be7880992f131b4f4e5f65e405..64d87bd132b5f0e1895f937096d931f64e2e67a4 100644 (file)
@@ -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