]> granicus.if.org Git - clang/commitdiff
make clang print types as "const int *" instead of "int const*",
authorChris Lattner <sabre@nondot.org>
Sun, 5 Sep 2010 00:04:01 +0000 (00:04 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 5 Sep 2010 00:04:01 +0000 (00:04 +0000)
which is should have done from the beginning.  As usual, the most
fun with this sort of change is updating all the testcases.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113090 91177308-0d34-0410-b5e6-96231b3b80d8

45 files changed:
lib/AST/Type.cpp
lib/AST/TypePrinter.cpp
test/Analysis/dead-stores.c
test/Analysis/exercise-ps.c
test/Analysis/uninit-vals.c
test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp
test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp
test/CXX/dcl.decl/dcl.init/p6.cpp
test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp
test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp
test/CXX/temp/temp.decls/temp.mem/p5.cpp
test/Index/complete-exprs.c
test/Rewriter/finally.m
test/Sema/address_spaces.c
test/Sema/array-constraint.c
test/Sema/asm.c
test/Sema/block-call.c
test/Sema/block-return.c
test/Sema/implicit-builtin-decl.c
test/Sema/knr-def-call.c
test/Sema/predef.c
test/Sema/vector-assign.c
test/Sema/warn-write-strings.c
test/SemaCXX/ambig-user-defined-conversions.cpp
test/SemaCXX/ambiguous-builtin-unary-operator.cpp
test/SemaCXX/builtin-ptrtomember-ambig.cpp
test/SemaCXX/class.cpp
test/SemaCXX/composite-pointer-type.cpp
test/SemaCXX/const-cast.cpp
test/SemaCXX/conversion-function.cpp
test/SemaCXX/cstyle-cast.cpp
test/SemaCXX/dcl_init_aggr.cpp
test/SemaCXX/decl-init-ref.cpp
test/SemaCXX/functional-cast.cpp
test/SemaCXX/new-delete.cpp
test/SemaCXX/overload-call.cpp
test/SemaCXX/overload-member-call.cpp
test/SemaCXX/references.cpp
test/SemaCXX/reinterpret-cast.cpp
test/SemaCXX/static-cast.cpp
test/SemaObjC/conditional-expr-4.m
test/SemaObjC/warn-write-strings.m
test/SemaObjCXX/message.mm
test/SemaTemplate/instantiate-expr-4.cpp
test/SemaTemplate/instantiation-default-1.cpp

index ccd26f8ba2efd76cc92cf8e66193003f48e759dd..ca10532e729e1729e58379da3fd765a709f94bab 100644 (file)
@@ -1040,7 +1040,7 @@ void FunctionProtoType::Profile(llvm::FoldingSetNodeID &ID) {
 }
 
 /// LookThroughTypedefs - Return the ultimate type this typedef corresponds to
-/// potentially looking through *all* consecutive typedefs.  This returns the
+/// potentially looking through *all* consequtive typedefs.  This returns the
 /// sum of the type qualifiers, so if you have:
 ///   typedef const int A;
 ///   typedef volatile A B;
index d3a6b645537c831240180ec749c22267eb21fe60..e21f9ac3ae4f448684511fb27ea6cfcb3d0e7547 100644 (file)
@@ -66,7 +66,15 @@ void TypePrinter::Print(QualType T, std::string &S) {
   
   // Print qualifiers as appropriate.
   Qualifiers Quals = T.getLocalQualifiers();
-  if (!Quals.empty()) {
+  
+  // CanPrefixQualifiers - We prefer to print type qualifiers before the type,
+  // so that we get "const int" instead of "int const", but we can't do this if
+  // the type is complex.  For example if the type is "int*", we *must* print
+  // "int * const", printing "const int *" is different.  Only do this when the
+  // type expands to a simple string.
+  bool CanPrefixQualifiers = isa<BuiltinType>(T);
+  
+  if (!CanPrefixQualifiers && !Quals.empty()) {
     std::string TQS;
     Quals.getAsStringInternal(TQS, Policy);
     
@@ -84,6 +92,18 @@ void TypePrinter::Print(QualType T, std::string &S) {
     break;
 #include "clang/AST/TypeNodes.def"
   }
+  
+  // If we're adding the qualifiers as a prefix, do it now.
+  if (CanPrefixQualifiers && !Quals.empty()) {
+    std::string TQS;
+    Quals.getAsStringInternal(TQS, Policy);
+    
+    if (!S.empty()) {
+      TQS += ' ';
+      TQS += S;
+    }
+    std::swap(S, TQS);
+  }
 }
 
 void TypePrinter::PrintBuiltin(const BuiltinType *T, std::string &S) {
index 57d5d112d717bd3b6802f25ed71faec5187e9d25..da131a298210b9e933cdb746002c596ce461db45 100644 (file)
@@ -13,7 +13,7 @@ void f1() {
 void f2(void *b) {
  char *c = (char*)b; // no-warning
  char *d = b+1; // expected-warning {{never read}} expected-warning{{unused variable 'd'}}
- printf("%s", c); // expected-warning{{implicitly declaring C library function 'printf' with type 'int (char const *, ...)'}} \
+ printf("%s", c); // expected-warning{{implicitly declaring C library function 'printf' with type 'int (const char *, ...)'}} \
  // expected-note{{please include the header <stdio.h> or explicitly provide a declaration for 'printf'}}
 }
 
index 0a95b7055601c502393108fa1fc3c0ec207fdcfa..196b67936a9ce6ad846d9024a09ecef6682de29c 100644 (file)
@@ -19,6 +19,6 @@ void_typedef f2_helper();
 static void f2(void *buf) {
   F12_typedef* x;
   x = f2_helper();
-  memcpy((&x[1]), (buf), 1); // expected-warning{{implicitly declaring C library function 'memcpy' with type 'void *(void *, void const *}} \
+  memcpy((&x[1]), (buf), 1); // expected-warning{{implicitly declaring C library function 'memcpy' with type 'void *(void *, const void *}} \
   // expected-note{{please include the header <string.h> or explicitly provide a declaration for 'memcpy'}}
 }
index b0769ba6bce1efbabfd2e7d96ad6e4aa9347b0e9..e4395e8486611b34a258746b48c5d45f38bd7061 100644 (file)
@@ -32,7 +32,7 @@ void f6(int i) {
   int x;
   for (i = 0 ; i < 10; i++)
     printf("%d",x++); // expected-warning {{use of uninitialized variable}} \
-  // expected-warning{{implicitly declaring C library function 'printf' with type 'int (char const *, ...)'}} \
+  // expected-warning{{implicitly declaring C library function 'printf' with type 'int (const char *, ...)'}} \
   // expected-note{{please include the header <stdio.h> or explicitly provide a declaration for 'printf'}}
 }
 
index 9b3925969c45a7c209be8e14bd1b1d40b70cdf36..b50bcb9aec8e1e4dda73280048da612eb33037b7 100644 (file)
@@ -6,8 +6,8 @@ void example0() {
   // CHECK: double &rd =
   // CHECK-NEXT: DeclRefExpr
   double &rd = d;
-  // CHECK: double const &rcd =
-  // CHECK-NEXT: ImplicitCastExpr{{.*}}'double const' <NoOp>
+  // CHECK: const double &rcd =
+  // CHECK-NEXT: ImplicitCastExpr{{.*}}'const double' <NoOp>
   const double &rcd = d;
 }
 
@@ -47,7 +47,7 @@ void example2() {
 
 // CHECK: example3
 void example3() {
-  // CHECK: double const &rcd2 =
+  // CHECK: const double &rcd2 =
   // CHECK: ImplicitCastExpr{{.*}}<IntegralToFloating>
   const double& rcd2 = 2; 
 }
index 6a039b93ebfabddce5f8b6ac34037dcdee2d7cd4..382488a9b6e467ee79dc6f4be2a1713d2d188140 100644 (file)
@@ -67,7 +67,7 @@ void bind_lvalue_quals(volatile Base b, volatile Derived d,
   volatile Base &bvr3 = bvc; // expected-error{{binding of reference to type 'Base volatile' to a value of type 'Base const volatile' drops qualifiers}}
   volatile Base &bvr4 = dvc; // expected-error{{binding of reference to type 'Base volatile' to a value of type 'Derived const volatile' drops qualifiers}}
   
-  volatile int &ir = ivc; // expected-error{{binding of reference to type 'int volatile' to a value of type 'int const volatile' 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}}
 
   const volatile Base &bcvr1 = b;
   const volatile Base &bcvr2 = d;
index c542dac1db1d9d4737cc67ac4c17065ecc316d53..7767761b1dcb8c99cae9b357fed9ef799205c70e 100644 (file)
@@ -12,5 +12,5 @@ struct HasUserDefault { HasUserDefault(); };
 void test_const_default_init() {
   const NoUserDefault x1; // expected-error{{default initialization of an object of const type 'NoUserDefault const' requires a user-provided default constructor}}
   const HasUserDefault x2;
-  const int x3; // expected-error{{default initialization of an object of const type 'int const'}}
+  const int x3; // expected-error{{default initialization of an object of const type 'const int'}}
 }
index ac0ec85db06083994d8fae4dff781c2a8b9f1df8..f032bf9979e29b5594564eb9cc0b53a99d157952 100644 (file)
@@ -5,7 +5,7 @@ int ar1[10];
 
 // Element type cannot be:
 // - (cv) void
-volatile void ar2[10]; // expected-error {{incomplete element type 'void volatile'}}
+volatile void ar2[10]; // expected-error {{incomplete element type 'volatile void'}}
 // - a reference
 int& ar3[10]; // expected-error {{array of references}}
 // - a function type
index b0f1c46a5226a9bbc3503dfe475f8cef1c120035..44e65f29ca34df9f86b7d0f27c4a3e6b2a262044 100644 (file)
@@ -88,19 +88,19 @@ namespace reference_parameters {
   extern const volatile int cvi;
   void test() {
     S0<i> s0;
-    S0<ci> s0c; // expected-error{{reference binding of non-type template parameter of type 'int &' to template argument of type 'int const' ignores qualifiers}}
-    S0<vi> s0v; // expected-error{{reference binding of non-type template parameter of type 'int &' to template argument of type 'int volatile' ignores qualifiers}}
-    S0<cvi> s0cv; // expected-error{{reference binding of non-type template parameter of type 'int &' to template argument of type 'int const volatile' ignores qualifiers}}
+    S0<ci> s0c; // expected-error{{reference binding of non-type template parameter of type 'int &' to template argument of type 'const int' ignores qualifiers}}
+    S0<vi> s0v; // expected-error{{reference binding of non-type template parameter of type 'int &' to template argument of type 'volatile int' ignores qualifiers}}
+    S0<cvi> s0cv; // expected-error{{reference binding of non-type template parameter of type 'int &' to template argument of type 'const volatile int' ignores qualifiers}}
 
     S1<i> s1;
     S1<ci> s1c;
-    S1<vi> s1v; // expected-error{{reference binding of non-type template parameter of type 'int const &' to template argument of type 'int volatile' ignores qualifiers}}
-    S1<cvi> s1cv; // expected-error{{reference binding of non-type template parameter of type 'int const &' to template argument of type 'int const volatile' ignores qualifiers}}
+    S1<vi> s1v; // expected-error{{reference binding of non-type template parameter of type 'const int &' to template argument of type 'volatile int' ignores qualifiers}}
+    S1<cvi> s1cv; // expected-error{{reference binding of non-type template parameter of type 'const int &' to template argument of type 'const volatile int' ignores qualifiers}}
 
     S2<i> s2;
-    S2<ci> s2c; // expected-error{{reference binding of non-type template parameter of type 'int volatile &' to template argument of type 'int const' ignores qualifiers}}
+    S2<ci> s2c; // expected-error{{reference binding of non-type template parameter of type 'volatile int &' to template argument of type 'const int' ignores qualifiers}}
     S2<vi> s2v;
-    S2<cvi> s2cv; // expected-error{{reference binding of non-type template parameter of type 'int volatile &' to template argument of type 'int const volatile' ignores qualifiers}}
+    S2<cvi> s2cv; // expected-error{{reference binding of non-type template parameter of type 'volatile int &' to template argument of type 'const volatile int' ignores qualifiers}}
 
     S3<i> s3;
     S3<ci> s3c;
index b0078d4bdb6d6cc1fa74b93fe477473afd5b80d1..7adc6f06da375b6d8ddd9a3cd88e0eaeff3cf103 100644 (file)
@@ -67,8 +67,8 @@ struct X0 {
   }
 };
 
-template X0::operator const char*() const; // expected-note{{'X0::operator char const *<char>' requested here}}
-template X0::operator const int*(); // expected-note{{'X0::operator int const *<int const>' requested here}}
+template X0::operator const char*() const; // expected-note{{'X0::operator const char *<char>' requested here}}
+template X0::operator const int*(); // expected-note{{'X0::operator const int *<const int>' requested here}}
 template X0::operator float*() const; // expected-error{{explicit instantiation of undefined function template}}
 
 void test_X0(X0 x0, const X0 &x0c) {
index 2a7a1e2121220c420e9907d6959ba1fd770b5d25..fd84d1c0e3947f8909fe26a69bbbf208d4b7c11f 100644 (file)
@@ -48,6 +48,6 @@ void f4(const char* str) {
 // CHECK-CC4: VarDecl:{ResultType struct X}{TypedText f1} (50) (deprecated)
 
 // RUN: c-index-test -code-completion-at=%s:19:3 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC6 %s
-// CHECK-CC6: FunctionDecl:{ResultType void}{TypedText f3}{LeftParen (}{Placeholder char const *, ...}{Text , NULL}{RightParen )} (45)
+// CHECK-CC6: FunctionDecl:{ResultType void}{TypedText f3}{LeftParen (}{Placeholder const char *, ...}{Text , NULL}{RightParen )} (45)
 // CHECK-CC6: NotImplemented:{TypedText void} (65)
 // CHECK-CC6: NotImplemented:{TypedText volatile} (65)
index 67774b5d9cda200e52801d6e56cb0f8d906f4233..7d160cfbdd2b1bb0190d1e11b2b30544c3b26e35 100644 (file)
@@ -2,7 +2,7 @@
 
 int main() {
   @try {
-    printf("executing try"); // expected-warning{{implicitly declaring C library function 'printf' with type 'int (char const *, ...)'}} \
+    printf("executing try"); // expected-warning{{implicitly declaring C library function 'printf' with type 'int (const char *, ...)'}} \
         // expected-note{{please include the header <stdio.h> or explicitly provide a declaration for 'printf'}}
     return(0); // expected-warning{{rewriter doesn't support user-specified control flow semantics for @try/@finally (code may not execute properly)}}
   } @finally {
index 23c1405011a3d7d0925cd0f2f4c8be0f9d7e6dce..538deda0c2f0075a3236372df93f8f88eaae2ac1 100644 (file)
@@ -37,6 +37,6 @@ struct _st {
 __attribute__((address_space(256))) void * * const base = 0;
 void * get_0(void) {
   return base[0];  // expected-error {{illegal implicit conversion between two pointers with different address spaces}} \
-                      expected-warning {{returning 'void __attribute__((address_space(256))) *' from a function with result type 'void *' discards qualifiers}}
+                      expected-warning {{returning '__attribute__((address_space(256))) void *' from a function with result type 'void *' discards qualifiers}}
 }
 
index 9fcac25abe968f1e568e5dce5c8d21a9efc15bb1..fe7fdc71155e8441113f938d7c62cd351c46cc23 100644 (file)
@@ -46,7 +46,7 @@ typedef int TA[I]; // expected-error {{variable length array declaration not all
 void strFunc(char *); // expected-note{{passing argument to parameter here}}
 const char staticAry[] = "test";
 void checkStaticAry() { 
-  strFunc(staticAry); // expected-warning{{passing 'char const [5]' to parameter of type 'char *' discards qualifiers}}
+  strFunc(staticAry); // expected-warning{{passing 'const char [5]' to parameter of type 'char *' discards qualifiers}}
 }
 
 
index 6f2272da9e775cf6dcb6af55ba8d161930e84c16..52611faf3dbc1a86bbcd684ff6c36838f460d4ba 100644 (file)
@@ -36,7 +36,7 @@ void test3() {
 // <rdar://problem/6156893>
 void test4(const volatile void *addr)
 {
-    asm ("nop" : : "r"(*addr)); // expected-error {{invalid type 'void const volatile' in asm input for constraint 'r'}}
+    asm ("nop" : : "r"(*addr)); // expected-error {{invalid type 'const volatile void' in asm input for constraint 'r'}}
     asm ("nop" : : "m"(*addr));
 
     asm ("nop" : : "r"(test4(addr))); // expected-error {{invalid type 'void' in asm input for constraint 'r'}}
index 27e4cfc6d46b8509830bffc14012b1663044d8d8..fbf0da4eb8b2777d4b080c316cc7741d7cc33c9a 100644 (file)
@@ -13,7 +13,7 @@ int main() {
   int (^IFP) () = PFR; // OK
 
 
-  const int (^CIC) () = IFP; // expected-error {{incompatible block pointer types initializing 'int const (^)()' with an expression of type 'int (^)()'}}
+  const int (^CIC) () = IFP; // expected-error {{incompatible block pointer types initializing 'const int (^)()' with an expression of type 'int (^)()'}}
 
   const int (^CICC) () = CIC;
 
index 5a4ec010d3a2113b358e1f9fc8024ac7daf35323..c6fcbe78eed7653965519ff72f9326dfa12cd383 100644 (file)
@@ -78,10 +78,10 @@ static int funk(char *s) {
 }
 void next();
 void foo4() {
-  int (^xx)(const char *s) = ^(char *s) { return 1; }; // expected-error {{incompatible block pointer types initializing 'int (^)(char const *)' with an expression of type 'int (^)(char *)'}}
-  int (*yy)(const char *s) = funk; // expected-warning {{incompatible pointer types initializing 'int (*)(char const *)' with an expression of type 'int (char *)'}}
+  int (^xx)(const char *s) = ^(char *s) { return 1; }; // expected-error {{incompatible block pointer types initializing 'int (^)(const char *)' with an expression of type 'int (^)(char *)'}}
+  int (*yy)(const char *s) = funk; // expected-warning {{incompatible pointer types initializing 'int (*)(const char *)' with an expression of type 'int (char *)'}}
   
-  int (^nested)(char *s) = ^(char *str) { void (^nest)(void) = ^(void) { printf("%s\n", str); }; next(); return 1; }; // expected-warning{{implicitly declaring C library function 'printf' with type 'int (char const *, ...)'}} \
+  int (^nested)(char *s) = ^(char *str) { void (^nest)(void) = ^(void) { printf("%s\n", str); }; next(); return 1; }; // expected-warning{{implicitly declaring C library function 'printf' with type 'int (const char *, ...)'}} \
   // expected-note{{please include the header <stdio.h> or explicitly provide a declaration for 'printf'}}
 }
 
@@ -109,7 +109,7 @@ void foo6() {
 
 void foo7()
 {
- const int (^BB) (void) = ^{ const int i = 1; return i; }; // expected-error{{incompatible block pointer types initializing 'int const (^)(void)' with an expression of type 'int (^)(void)'}}
+ const int (^BB) (void) = ^{ const int i = 1; return i; }; // expected-error{{incompatible block pointer types initializing 'const int (^)(void)' with an expression of type 'int (^)(void)'}}
 
  const int (^CC) (void)  = ^const int{ const int i = 1; return i; };
 
index 3d920389a228fdfe6ce0cd1ecd0fab1063eb7207..9e01de1c859838b47192023f24c48c5af36e2b97 100644 (file)
@@ -18,7 +18,7 @@ void g(int malloc) { // okay: these aren't functions
 void h() {
   int malloc(int); // expected-warning{{incompatible redeclaration of library function 'malloc'}}
   int strcpy(int); // expected-warning{{incompatible redeclaration of library function 'strcpy'}} \
-  // expected-note{{'strcpy' is a builtin with type 'char *(char *, char const *)'}}
+  // expected-note{{'strcpy' is a builtin with type 'char *(char *, const char *)'}}
 }
 
 void f2() {
index 66f2ec07f287f86364114073089e0cc27cd051e3..fd06cbf6457444a4bf6304a7b025f8bf389299dc 100644 (file)
@@ -23,7 +23,7 @@ void f4() {
 }
 
 char *rindex(s, c)
-     register char *s, c; // expected-warning{{promoted type 'char *' of K&R function parameter is not compatible with the parameter type 'char const *' declared in a previous prototype}}
+     register char *s, c; // expected-warning{{promoted type 'char *' of K&R function parameter is not compatible with the parameter type 'const char *' declared in a previous prototype}}
 {
   return 0;
 }
index 08a4a2bf83e9f3ca34918009f3518d5883c3270a..95bcfb9d8d51026614985b1ed52ab392ddd70242 100644 (file)
@@ -6,7 +6,7 @@ void abcdefghi12(void) {
 }
 
 char *X = __func__; // expected-warning {{predefined identifier is only valid}} \
-                       expected-warning {{initializing 'char *' with an expression of type 'char const [1]' discards qualifiers}}
+                       expected-warning {{initializing 'char *' with an expression of type 'const char [1]' discards qualifiers}}
 
 void a() {
   __func__[0] = 'a';  // expected-error {{variable is not assignable}}
index 05fc3b13db0c94e605dd324af7686488d7b6f5a6..8b0dc9288ee0cb6c4dbc67ca031451f329b3db3e 100644 (file)
@@ -49,5 +49,5 @@ longlongvec;
 
 void test3a(longlongvec *); // expected-note{{passing argument to parameter here}}
 void test3(const unsigned *src) {
-  test3a(src);  // expected-warning {{incompatible pointer types passing 'unsigned int const *' to parameter of type 'longlongvec *'}}
+  test3a(src);  // expected-warning {{incompatible pointer types passing 'const unsigned int *' to parameter of type 'longlongvec *'}}
 }
index 04af00ca2d835b87e0841d700a4260b06753d5e7..450d0a6fe62e64115df318b1e4f06be66dcd7174 100644 (file)
@@ -1,4 +1,4 @@
 // RUN: %clang_cc1 -verify -fsyntax-only -Wwrite-strings %s
 
 // PR4804
-char* x = "foo"; // expected-warning {{initializing 'char *' with an expression of type 'char const [4]' discards qualifiers}}
+char* x = "foo"; // expected-warning {{initializing 'char *' with an expression of type 'const char [4]' discards qualifiers}}
index fdb399b03a2168f6a0fe1e7b4f52d117134c83cb..dd8501adb62a858594dcbee9b6d95e2cb2ff7c7b 100644 (file)
@@ -20,7 +20,7 @@ namespace test0 {
   const int Test1() {
 
     func(b1, f()); // expected-error {{call to 'func' is ambiguous}}
-    return f(); // expected-error {{conversion from 'test0::B' to 'int const' is ambiguous}}
+    return f(); // expected-error {{conversion from 'test0::B' to 'const int' is ambiguous}}
   }
 
   // This used to crash when comparing the two operands.
index 1aa09a6827a0f1c7cc3cfc2f67868831344acb8c..836e319f84044ea03f3e717dbc229ed1ea5d3a0f 100644 (file)
@@ -28,7 +28,7 @@ struct C1 : B1, A1 { };
 
 void test(C1 c) {
   ++c; // expected-error {{use of overloaded operator '++' is ambiguous}} \
-       // expected-note {{built-in candidate operator++(int volatile &)}} \
-       // expected-note {{built-in candidate operator++(long volatile &)}}
+       // expected-note {{built-in candidate operator++(volatile int &)}} \
+       // expected-note {{built-in candidate operator++(volatile long &)}}
 }
 
index 3e0dfbb48edaaf80c4448b79182a1b109f32002a..1b0460d09159e098355f5f34ba35a9cb878a08e6 100644 (file)
@@ -19,9 +19,9 @@ struct C : B {
 void foo(C c, int A::* pmf) {
                                        // FIXME. Why so many built-in candidates?
        int i = c->*pmf;        // expected-error {{use of overloaded operator '->*' is ambiguous}} \
-                               // expected-note {{built-in candidate operator->*(struct A const *, int const struct A::*)}} \
+                               // expected-note {{built-in candidate operator->*(struct A const *, const int struct A::*)}} \
                                // expected-note {{built-in candidate operator->*(struct A const *, int struct A::*)}} \
-                               // expected-note {{built-in candidate operator->*(struct A *, int const struct A::*)}} \
+                               // expected-note {{built-in candidate operator->*(struct A *, const int struct A::*)}} \
                                // expected-note {{built-in candidate operator->*(struct A *, int struct A::*)}}
 }
 
index 9d9508b8ef4a6b9208fdaef78b85e29c7ea5c4dc..e51d0fdff97bd78a603432fdf2d7ecf0f8a141dc 100644 (file)
@@ -89,7 +89,7 @@ struct C3 {
 void f()
 {
   const C3 c3 = { 1, 2 };
-  (void)static_cast<int*>(&c3.i); // expected-error {{static_cast from 'int const *' to 'int *' is not allowed}}
+  (void)static_cast<int*>(&c3.i); // expected-error {{static_cast from 'const int *' to 'int *' is not allowed}}
   // but no error here
   (void)static_cast<int*>(&c3.j);
 }
index e8b09204d197869b3be0b2f8b33f49fbdd9dac40..06fc8f43855d6ed05e6cdc835dea43f0bb4a299b 100644 (file)
@@ -53,8 +53,8 @@ bool f(Matrix4 m1, const Matrix4 m2) {
 
 // PR6346
 bool f1(bool b, void **p, const void **q) {
-  if (p == q) // expected-warning{{comparison of distinct pointer types ('void **' and 'void const **') uses non-standard composite pointer type 'void const *const *'}}
+  if (p == q) // expected-warning{{comparison of distinct pointer types ('void **' and 'const void **') uses non-standard composite pointer type 'const void *const *'}}
     return false;
 
-  return b? p : q; // expected-warning{{incompatible operand types ('void **' and 'void const **') use non-standard composite pointer type 'void const *const *'}}
+  return b? p : q; // expected-warning{{incompatible operand types ('void **' and 'const void **') use non-standard composite pointer type 'const void *const *'}}
 }
index 50bd3162780b14dd978d20d1a029e3af4d8d42b0..62851f81280f4402c265b70d6f09e19376b5b4a6 100644 (file)
@@ -45,16 +45,16 @@ char ***good_const_cast_test(ccvpcvpp var)
 short *bad_const_cast_test(char const *volatile *const volatile *var)
 {
   // Different pointer levels.
-  char **var2 = const_cast<char**>(var); // expected-error {{const_cast from 'char const *volatile *const volatile *' to 'char **' is not allowed}}
+  char **var2 = const_cast<char**>(var); // expected-error {{const_cast from 'const char *volatile *const volatile *' to 'char **' is not allowed}}
   // Different final type.
-  short ***var3 = const_cast<short***>(var); // expected-error {{const_cast from 'char const *volatile *const volatile *' to 'short ***' is not allowed}}
+  short ***var3 = const_cast<short***>(var); // expected-error {{const_cast from 'const char *volatile *const volatile *' to 'short ***' is not allowed}}
   // Rvalue to reference.
   char ***&var4 = const_cast<cpppr>(&var2); // expected-error {{const_cast from rvalue to reference type 'cpppr'}}
   // Non-pointer.
   char v = const_cast<char>(**var2); // expected-error {{const_cast to 'char', which is not a reference, pointer-to-object, or pointer-to-data-member}}
   const int *ar[100] = {0};
   // Not even lenient g++ accepts this.
-  int *(*rar)[100] = const_cast<int *(*)[100]>(&ar); // expected-error {{const_cast from 'int const *(*)[100]' to 'int *(*)[100]' is not allowed}}
+  int *(*rar)[100] = const_cast<int *(*)[100]>(&ar); // expected-error {{const_cast from 'const int *(*)[100]' to 'int *(*)[100]' is not allowed}}
   f fp1 = 0;
   // Function pointers.
   f fp2 = const_cast<f>(fp1); // expected-error {{const_cast to 'f' (aka 'int (*)(int)'), which is not a reference, pointer-to-object, or pointer-to-data-member}}
index 07281e16d3f3f0b6c7987e816474d4a88ac94f1f..7f8fdd534007d6e36d17d4324ec7e8b229459aa7 100644 (file)
@@ -50,7 +50,7 @@ class A { };
 class B : public A {
 public:
   operator A&() const; // expected-warning{{conversion function converting 'B' to its base class 'A' will never be used}}
-  operator const void() const; // expected-warning{{conversion function converting 'B' to 'void const' will never be used}}
+  operator const void() const; // expected-warning{{conversion function converting 'B' to 'const void' will never be used}}
   operator const B(); // expected-warning{{conversion function converting 'B' to itself will never be used}}
 };
 
index ccb25f00c24e17d41b6ee81ed5b40eac8bbf6bdf..12495ecdc5c195a01c3780d521b46b705babc34f 100644 (file)
@@ -226,6 +226,6 @@ void memptrs()
   void (structure::*psf)() = 0;
   (void)(int (structure::*)())(psf);
 
-  (void)(void (structure::*)())(psi); // expected-error {{C-style cast from 'int const structure::*' to 'void (structure::*)()' is not allowed}}
+  (void)(void (structure::*)())(psi); // expected-error {{C-style cast from 'const int structure::*' to 'void (structure::*)()' is not allowed}}
   (void)(int structure::*)(psf); // expected-error {{C-style cast from 'void (structure::*)()' to 'int structure::*' is not allowed}}
 }
index 8b286634446278011182cf6960a2affc2869ad26..2dbd381e4dba2d7ebe1623fb7d048622aa6e1d23 100644 (file)
@@ -120,4 +120,4 @@ u u1 = { 1 };
 u u2 = u1; 
 u u3 = 1; // expected-error{{no viable conversion}}
 u u4 = { 0, "asdf" };  // expected-error{{excess elements in union initializer}}
-u u5 = { "asdf" }; // expected-error{{cannot initialize a member subobject of type 'int' with an lvalue of type 'char const [5]'}}
+u u5 = { "asdf" }; // expected-error{{cannot initialize a member subobject of type 'int' with an lvalue of type 'const char [5]'}}
index 7ae043925214ba28bfe137c08b16cf533300283c..922f0b780486d163fb2be0b1be79e064d926b58a 100644 (file)
@@ -18,7 +18,7 @@ class B : public BASE , public BASE1
 
 extern B f();
 
-const int& ri = (void)0; // expected-error {{reference to type 'int const' could not bind to an rvalue of type 'void'}}
+const int& ri = (void)0; // expected-error {{reference to type 'const int' could not bind to an rvalue of type 'void'}}
 
 int main() {
         const A& rca = f(); // expected-error {{reference initialization of type 'A const &' with initializer of type 'B' is ambiguous}}
index 3b088645a65b2cecbc67a2cfcdace66fd077fe25..2f63c203857999f0daa73b4e7b9bfa887ffbad7d 100644 (file)
@@ -304,7 +304,7 @@ void memptrs()
   (void)structureimfp(psf);
 
   typedef void (structure::*structurevmfp)();
-  (void)structurevmfp(psi); // expected-error {{functional-style cast from 'int const structure::*' to 'structurevmfp' (aka 'void (structure::*)()') is not allowed}}
+  (void)structurevmfp(psi); // expected-error {{functional-style cast from 'const int structure::*' to 'structurevmfp' (aka 'void (structure::*)()') is not allowed}}
   (void)structureimp(psf); // expected-error {{functional-style cast from 'void (structure::*)()' to 'structureimp' (aka 'int structure::*') is not allowed}}
 }
 
index 9a64e4c01d7e1205365dea1a3a8d4eb3b070efd5..ef20aee009c4841246b2e986b3e22e97263a18aa 100644 (file)
@@ -73,7 +73,7 @@ void bad_news(int *ip)
   (void)new int(1, 2); // expected-error {{excess elements in scalar initializer}}
   (void)new S(1); // expected-error {{no matching constructor}}
   (void)new S(1, 1); // expected-error {{call to constructor of 'S' is ambiguous}}
-  (void)new const int; // expected-error {{default initialization of an object of const type 'int const'}}
+  (void)new const int; // expected-error {{default initialization of an object of const type 'const int'}}
   (void)new float*(ip); // expected-error {{cannot initialize a new value of type 'float *' with an lvalue of type 'int *'}}
   // Undefined, but clang should reject it directly.
   (void)new int[-1]; // expected-error {{array size is negative}}
index 6bf6965e46bfe777466302fcc7963939f7c245cf..d97bacc63dda3b59ff89274ca5f93f340cf309ac 100644 (file)
@@ -317,8 +317,8 @@ namespace PR5756 {
 
 // Tests the exact text used to note the candidates
 namespace test1 {
-  template <class T> void foo(T t, unsigned N); // expected-note {{candidate function [with T = int] not viable: no known conversion from 'char const [6]' to 'unsigned int' for 2nd argument}}
-  void foo(int n, char N); // expected-note {{candidate function not viable: no known conversion from 'char const [6]' to 'char' for 2nd argument}} 
+  template <class T> void foo(T t, unsigned N); // expected-note {{candidate function [with T = int] not viable: no known conversion from 'const char [6]' to 'unsigned int' for 2nd argument}}
+  void foo(int n, char N); // expected-note {{candidate function not viable: no known conversion from 'const char [6]' to 'char' for 2nd argument}} 
   void foo(int n); // expected-note {{candidate function not viable: requires 1 argument, but 2 were provided}}
   void foo(unsigned n = 10); // expected-note {{candidate function not viable: requires at most 1 argument, but 2 were provided}}
   void foo(int n, const char *s, int t); // expected-note {{candidate function not viable: requires 3 arguments, but 2 were provided}}
@@ -441,7 +441,7 @@ namespace PR6177 {
   void f(bool const volatile&); // expected-note{{passing argument to parameter here}}
   void f(String);
 
-  void g() { f(""); } // expected-error{{volatile lvalue reference to type 'bool const volatile' cannot bind to a value of unrelated type 'char const [1]'}}
+  void g() { f(""); } // expected-error{{volatile lvalue reference to type 'const volatile bool' cannot bind to a value of unrelated type 'const char [1]'}}
 }
 
 namespace PR7095 {
index 8016b116812f3e399bddbbab9473757a92c53c30..885a950a771b7373cb5a588891624860d63e343f 100644 (file)
@@ -70,8 +70,8 @@ void test_X2(X2 *x2p, const X2 *cx2p) {
 // Tests the exact text used to note the candidates
 namespace test1 {
   class A {
-    template <class T> void foo(T t, unsigned N); // expected-note {{candidate function [with T = int] not viable: no known conversion from 'char const [6]' to 'unsigned int' for 2nd argument}}
-    void foo(int n, char N); // expected-note {{candidate function not viable: no known conversion from 'char const [6]' to 'char' for 2nd argument}} 
+    template <class T> void foo(T t, unsigned N); // expected-note {{candidate function [with T = int] not viable: no known conversion from 'const char [6]' to 'unsigned int' for 2nd argument}}
+    void foo(int n, char N); // expected-note {{candidate function not viable: no known conversion from 'const char [6]' to 'char' for 2nd argument}} 
     void foo(int n); // expected-note {{candidate function not viable: requires 1 argument, but 2 were provided}}
     void foo(unsigned n = 10); // expected-note {{candidate function not viable: requires at most 1 argument, but 2 were provided}}
     void foo(int n, const char *s, int t); // expected-note {{candidate function not viable: requires 3 arguments, but 2 were provided}}
index a7aafe41c392d754918dd5e00901a4ec803fe984..996e7da90b4ca784ef1b6195e55d629aa3f4597b 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 'int const' to a value of type 'int const volatile' drops qualifiers}}
+  const int& r = cvi; // expected-error{{binding of reference to type 'const int' to a value of type 'const volatile int' drops qualifiers}}
 }
 
 // C++ [dcl.init.ref]p3
index f054e528d2d8463ff810788ffdd73300cfb6c10f..335fe7edbcf36e108a57e88a8ec1fa40c414c7dc 100644 (file)
@@ -45,9 +45,9 @@ void constness()
   // Valid: T1* -> T2 const*
   int const *icp = reinterpret_cast<int const*>(ipppc);
   // Invalid: T1 const* -> T2*
-  (void)reinterpret_cast<int*>(icp); // expected-error {{reinterpret_cast from 'int const *' to 'int *' casts away constness}}
+  (void)reinterpret_cast<int*>(icp); // expected-error {{reinterpret_cast from 'const int *' to 'int *' casts away constness}}
   // Invalid: T1*** -> T2 const* const**
-  int const *const **icpcpp = reinterpret_cast<int const* const**>(ipppc); // expected-error {{reinterpret_cast from 'int ***' to 'int const *const **' casts away constness}}
+  int const *const **icpcpp = reinterpret_cast<int const* const**>(ipppc); // expected-error {{reinterpret_cast from 'int ***' to 'const int *const **' casts away constness}}
   // Valid: T1* -> T2*
   int *ip = reinterpret_cast<int*>(icpcpp);
   // Valid: T* -> T const*
@@ -77,12 +77,12 @@ void memptrs()
 {
   const int structure::*psi = 0;
   (void)reinterpret_cast<const float structure::*>(psi);
-  (void)reinterpret_cast<int structure::*>(psi); // expected-error {{reinterpret_cast from 'int const structure::*' to 'int structure::*' casts away constness}}
+  (void)reinterpret_cast<int structure::*>(psi); // expected-error {{reinterpret_cast from 'const int structure::*' to 'int structure::*' casts away constness}}
 
   void (structure::*psf)() = 0;
   (void)reinterpret_cast<int (structure::*)()>(psf);
 
-  (void)reinterpret_cast<void (structure::*)()>(psi); // expected-error {{reinterpret_cast from 'int const structure::*' to 'void (structure::*)()' is not allowed}}
+  (void)reinterpret_cast<void (structure::*)()>(psi); // expected-error {{reinterpret_cast from 'const int structure::*' to 'void (structure::*)()' is not allowed}}
   (void)reinterpret_cast<int structure::*>(psf); // expected-error {{reinterpret_cast from 'void (structure::*)()' to 'int structure::*' is not allowed}}
 
   // Cannot cast from integers to member pointers, not even the null pointer
index 48f641aa997b2ae6b62f8454aa41b0d12836e6c1..9af200d574e80f8836191bc8efa606af23d6de0d 100644 (file)
@@ -55,7 +55,7 @@ void t_529_2()
 
   // Bad code below
 
-  (void)static_cast<void*>((const int*)0); // expected-error {{static_cast from 'int const *' to 'void *' is not allowed}}
+  (void)static_cast<void*>((const int*)0); // expected-error {{static_cast from 'const int *' to 'void *' is not allowed}}
   (void)static_cast<A*>((E*)0); // expected-error {{cannot cast 'E' to its private base class 'A'}}
   (void)static_cast<A*>((H*)0); // expected-error {{ambiguous conversion}}
   (void)static_cast<int>((int*)0); // expected-error {{static_cast from 'int *' to 'int' is not allowed}}
@@ -119,7 +119,7 @@ void t_529_10()
 
   // Bad code below
 
-  (void)static_cast<int*>((const void*)0); // expected-error {{static_cast from 'void const *' to 'int *' casts away constness}}
+  (void)static_cast<int*>((const void*)0); // expected-error {{static_cast from 'const void *' to 'int *' casts away constness}}
   (void)static_cast<void (*)()>((void*)0); // expected-error {{static_cast from 'void *' to 'void (*)()' is not allowed}}
 }
 
index b3317f58061db0ac0bafec2734a45e28c9b5b1d9..56bcfc2de6fd02ca23aa9d0bdc7b350282b26535 100644 (file)
@@ -26,7 +26,7 @@ A *f1_a(int cond, A *a) {
 }
 
 void *f1_const_a(int x, void *p, const A * q) {
-  void *r = x ? p : q; // expected-warning{{initializing 'void *' with an expression of type 'void const *' discards qualifiers}}
+  void *r = x ? p : q; // expected-warning{{initializing 'void *' with an expression of type 'const void *' discards qualifiers}}
   return r;
 }
 
index 04af00ca2d835b87e0841d700a4260b06753d5e7..450d0a6fe62e64115df318b1e4f06be66dcd7174 100644 (file)
@@ -1,4 +1,4 @@
 // RUN: %clang_cc1 -verify -fsyntax-only -Wwrite-strings %s
 
 // PR4804
-char* x = "foo"; // expected-warning {{initializing 'char *' with an expression of type 'char const [4]' discards qualifiers}}
+char* x = "foo"; // expected-warning {{initializing 'char *' with an expression of type 'const char [4]' discards qualifiers}}
index f92518ad48c1c52b2e1b2f05294511e27f4c9e19..ab86d9437f02bd7a52afcb45c7729b70ff39d63e 100644 (file)
@@ -90,5 +90,5 @@ struct MutableString : public String { };
 
 void test_I5(I5 *i5, String s) {
   [i5 method:"hello" other:s];
-  [i5 method:s other:"world"]; // expected-error{{non-const lvalue reference to type 'String' cannot bind to a value of unrelated type 'char const [6]'}}
+  [i5 method:s other:"world"]; // expected-error{{non-const lvalue reference to type 'String' cannot bind to a value of unrelated type 'const char [6]'}}
 }
index adae1da26aaf5b35a144c794ac14bb5bd0fe3b43..11efe5b7f397ba9a55da6280fdf796b777e49f03 100644 (file)
@@ -319,7 +319,7 @@ template struct NonDepMemberCall0<float&>; // expected-note{{instantiation}}
 template<typename T>
 struct QualifiedDeclRef0 {
   T f() {
-    return is_pod<X>::value; // expected-error{{non-const lvalue reference to type 'int' cannot bind to a value of unrelated type 'bool const'}}
+    return is_pod<X>::value; // expected-error{{non-const lvalue reference to type 'int' cannot bind to a value of unrelated type 'const bool'}}
   }
 };
 
index 6f5a660d99f1147a7494fd5342ed51f6975ff8b5..99154a5cc46066aadf2d69d458491ae81a2d5181 100644 (file)
@@ -36,7 +36,7 @@ typedef int& int_ref_t;
 Def2<int_ref_t> *d2; // expected-note{{in instantiation of default argument for 'Def2<int &>' required here}}
 
 
-template<> struct Def1<const int, const int> { }; // expected-error{{redefinition of 'Def1<int const>'}}
+template<> struct Def1<const int, const int> { }; // expected-error{{redefinition of 'Def1<const int>'}}
 
 template<typename T, typename T2 = T&> struct Def3;