diff options
45 files changed, 89 insertions, 69 deletions
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index ccd26f8ba2e..ca10532e729 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -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; diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp index d3a6b645537..e21f9ac3ae4 100644 --- a/clang/lib/AST/TypePrinter.cpp +++ b/clang/lib/AST/TypePrinter.cpp @@ -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) { diff --git a/clang/test/Analysis/dead-stores.c b/clang/test/Analysis/dead-stores.c index 57d5d112d71..da131a29821 100644 --- a/clang/test/Analysis/dead-stores.c +++ b/clang/test/Analysis/dead-stores.c @@ -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'}} } diff --git a/clang/test/Analysis/exercise-ps.c b/clang/test/Analysis/exercise-ps.c index 0a95b705560..196b67936a9 100644 --- a/clang/test/Analysis/exercise-ps.c +++ b/clang/test/Analysis/exercise-ps.c @@ -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'}} } diff --git a/clang/test/Analysis/uninit-vals.c b/clang/test/Analysis/uninit-vals.c index b0769ba6bce..e4395e84866 100644 --- a/clang/test/Analysis/uninit-vals.c +++ b/clang/test/Analysis/uninit-vals.c @@ -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'}} } diff --git a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp index 9b3925969c4..b50bcb9aec8 100644 --- a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp +++ b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp @@ -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; } diff --git a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp index 6a039b93ebf..382488a9b6e 100644 --- a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp +++ b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp @@ -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; diff --git a/clang/test/CXX/dcl.decl/dcl.init/p6.cpp b/clang/test/CXX/dcl.decl/dcl.init/p6.cpp index c542dac1db1..7767761b1dc 100644 --- a/clang/test/CXX/dcl.decl/dcl.init/p6.cpp +++ b/clang/test/CXX/dcl.decl/dcl.init/p6.cpp @@ -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'}} } diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp index ac0ec85db06..f032bf9979e 100644 --- a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp +++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp @@ -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 diff --git a/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp b/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp index b0f1c46a522..44e65f29ca3 100644 --- a/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp +++ b/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp @@ -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; diff --git a/clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp b/clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp index b0078d4bdb6..7adc6f06da3 100644 --- a/clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp +++ b/clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp @@ -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) { diff --git a/clang/test/Index/complete-exprs.c b/clang/test/Index/complete-exprs.c index 2a7a1e21212..fd84d1c0e39 100644 --- a/clang/test/Index/complete-exprs.c +++ b/clang/test/Index/complete-exprs.c @@ -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) diff --git a/clang/test/Rewriter/finally.m b/clang/test/Rewriter/finally.m index 67774b5d9cd..7d160cfbdd2 100644 --- a/clang/test/Rewriter/finally.m +++ b/clang/test/Rewriter/finally.m @@ -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 { diff --git a/clang/test/Sema/address_spaces.c b/clang/test/Sema/address_spaces.c index 23c1405011a..538deda0c2f 100644 --- a/clang/test/Sema/address_spaces.c +++ b/clang/test/Sema/address_spaces.c @@ -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}} } diff --git a/clang/test/Sema/array-constraint.c b/clang/test/Sema/array-constraint.c index 9fcac25abe9..fe7fdc71155 100644 --- a/clang/test/Sema/array-constraint.c +++ b/clang/test/Sema/array-constraint.c @@ -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}} } diff --git a/clang/test/Sema/asm.c b/clang/test/Sema/asm.c index 6f2272da9e7..52611faf3db 100644 --- a/clang/test/Sema/asm.c +++ b/clang/test/Sema/asm.c @@ -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'}} diff --git a/clang/test/Sema/block-call.c b/clang/test/Sema/block-call.c index 27e4cfc6d46..fbf0da4eb8b 100644 --- a/clang/test/Sema/block-call.c +++ b/clang/test/Sema/block-call.c @@ -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; diff --git a/clang/test/Sema/block-return.c b/clang/test/Sema/block-return.c index 5a4ec010d3a..c6fcbe78eed 100644 --- a/clang/test/Sema/block-return.c +++ b/clang/test/Sema/block-return.c @@ -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; }; diff --git a/clang/test/Sema/implicit-builtin-decl.c b/clang/test/Sema/implicit-builtin-decl.c index 3d920389a22..9e01de1c859 100644 --- a/clang/test/Sema/implicit-builtin-decl.c +++ b/clang/test/Sema/implicit-builtin-decl.c @@ -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() { diff --git a/clang/test/Sema/knr-def-call.c b/clang/test/Sema/knr-def-call.c index 66f2ec07f28..fd06cbf6457 100644 --- a/clang/test/Sema/knr-def-call.c +++ b/clang/test/Sema/knr-def-call.c @@ -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; } diff --git a/clang/test/Sema/predef.c b/clang/test/Sema/predef.c index 08a4a2bf83e..95bcfb9d8d5 100644 --- a/clang/test/Sema/predef.c +++ b/clang/test/Sema/predef.c @@ -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}} diff --git a/clang/test/Sema/vector-assign.c b/clang/test/Sema/vector-assign.c index 05fc3b13db0..8b0dc9288ee 100644 --- a/clang/test/Sema/vector-assign.c +++ b/clang/test/Sema/vector-assign.c @@ -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 *'}} } diff --git a/clang/test/Sema/warn-write-strings.c b/clang/test/Sema/warn-write-strings.c index 04af00ca2d8..450d0a6fe62 100644 --- a/clang/test/Sema/warn-write-strings.c +++ b/clang/test/Sema/warn-write-strings.c @@ -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}} diff --git a/clang/test/SemaCXX/ambig-user-defined-conversions.cpp b/clang/test/SemaCXX/ambig-user-defined-conversions.cpp index fdb399b03a2..dd8501adb62 100644 --- a/clang/test/SemaCXX/ambig-user-defined-conversions.cpp +++ b/clang/test/SemaCXX/ambig-user-defined-conversions.cpp @@ -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. diff --git a/clang/test/SemaCXX/ambiguous-builtin-unary-operator.cpp b/clang/test/SemaCXX/ambiguous-builtin-unary-operator.cpp index 1aa09a6827a..836e319f840 100644 --- a/clang/test/SemaCXX/ambiguous-builtin-unary-operator.cpp +++ b/clang/test/SemaCXX/ambiguous-builtin-unary-operator.cpp @@ -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 &)}} } diff --git a/clang/test/SemaCXX/builtin-ptrtomember-ambig.cpp b/clang/test/SemaCXX/builtin-ptrtomember-ambig.cpp index 3e0dfbb48ed..1b0460d0915 100644 --- a/clang/test/SemaCXX/builtin-ptrtomember-ambig.cpp +++ b/clang/test/SemaCXX/builtin-ptrtomember-ambig.cpp @@ -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::*)}} } diff --git a/clang/test/SemaCXX/class.cpp b/clang/test/SemaCXX/class.cpp index 9d9508b8ef4..e51d0fdff97 100644 --- a/clang/test/SemaCXX/class.cpp +++ b/clang/test/SemaCXX/class.cpp @@ -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); } diff --git a/clang/test/SemaCXX/composite-pointer-type.cpp b/clang/test/SemaCXX/composite-pointer-type.cpp index e8b09204d19..06fc8f43855 100644 --- a/clang/test/SemaCXX/composite-pointer-type.cpp +++ b/clang/test/SemaCXX/composite-pointer-type.cpp @@ -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 *'}} } diff --git a/clang/test/SemaCXX/const-cast.cpp b/clang/test/SemaCXX/const-cast.cpp index 50bd3162780..62851f81280 100644 --- a/clang/test/SemaCXX/const-cast.cpp +++ b/clang/test/SemaCXX/const-cast.cpp @@ -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}} diff --git a/clang/test/SemaCXX/conversion-function.cpp b/clang/test/SemaCXX/conversion-function.cpp index 07281e16d3f..7f8fdd53400 100644 --- a/clang/test/SemaCXX/conversion-function.cpp +++ b/clang/test/SemaCXX/conversion-function.cpp @@ -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}} }; diff --git a/clang/test/SemaCXX/cstyle-cast.cpp b/clang/test/SemaCXX/cstyle-cast.cpp index ccb25f00c24..12495ecdc5c 100644 --- a/clang/test/SemaCXX/cstyle-cast.cpp +++ b/clang/test/SemaCXX/cstyle-cast.cpp @@ -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}} } diff --git a/clang/test/SemaCXX/dcl_init_aggr.cpp b/clang/test/SemaCXX/dcl_init_aggr.cpp index 8b286634446..2dbd381e4db 100644 --- a/clang/test/SemaCXX/dcl_init_aggr.cpp +++ b/clang/test/SemaCXX/dcl_init_aggr.cpp @@ -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]'}} diff --git a/clang/test/SemaCXX/decl-init-ref.cpp b/clang/test/SemaCXX/decl-init-ref.cpp index 7ae04392521..922f0b78048 100644 --- a/clang/test/SemaCXX/decl-init-ref.cpp +++ b/clang/test/SemaCXX/decl-init-ref.cpp @@ -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}} diff --git a/clang/test/SemaCXX/functional-cast.cpp b/clang/test/SemaCXX/functional-cast.cpp index 3b088645a65..2f63c203857 100644 --- a/clang/test/SemaCXX/functional-cast.cpp +++ b/clang/test/SemaCXX/functional-cast.cpp @@ -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}} } diff --git a/clang/test/SemaCXX/new-delete.cpp b/clang/test/SemaCXX/new-delete.cpp index 9a64e4c01d7..ef20aee009c 100644 --- a/clang/test/SemaCXX/new-delete.cpp +++ b/clang/test/SemaCXX/new-delete.cpp @@ -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}} diff --git a/clang/test/SemaCXX/overload-call.cpp b/clang/test/SemaCXX/overload-call.cpp index 6bf6965e46b..d97bacc63dd 100644 --- a/clang/test/SemaCXX/overload-call.cpp +++ b/clang/test/SemaCXX/overload-call.cpp @@ -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 { diff --git a/clang/test/SemaCXX/overload-member-call.cpp b/clang/test/SemaCXX/overload-member-call.cpp index 8016b116812..885a950a771 100644 --- a/clang/test/SemaCXX/overload-member-call.cpp +++ b/clang/test/SemaCXX/overload-member-call.cpp @@ -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}} diff --git a/clang/test/SemaCXX/references.cpp b/clang/test/SemaCXX/references.cpp index a7aafe41c39..996e7da90b4 100644 --- a/clang/test/SemaCXX/references.cpp +++ b/clang/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 '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 diff --git a/clang/test/SemaCXX/reinterpret-cast.cpp b/clang/test/SemaCXX/reinterpret-cast.cpp index f054e528d2d..335fe7edbcf 100644 --- a/clang/test/SemaCXX/reinterpret-cast.cpp +++ b/clang/test/SemaCXX/reinterpret-cast.cpp @@ -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 diff --git a/clang/test/SemaCXX/static-cast.cpp b/clang/test/SemaCXX/static-cast.cpp index 48f641aa997..9af200d574e 100644 --- a/clang/test/SemaCXX/static-cast.cpp +++ b/clang/test/SemaCXX/static-cast.cpp @@ -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}} } diff --git a/clang/test/SemaObjC/conditional-expr-4.m b/clang/test/SemaObjC/conditional-expr-4.m index b3317f58061..56bcfc2de6f 100644 --- a/clang/test/SemaObjC/conditional-expr-4.m +++ b/clang/test/SemaObjC/conditional-expr-4.m @@ -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; } diff --git a/clang/test/SemaObjC/warn-write-strings.m b/clang/test/SemaObjC/warn-write-strings.m index 04af00ca2d8..450d0a6fe62 100644 --- a/clang/test/SemaObjC/warn-write-strings.m +++ b/clang/test/SemaObjC/warn-write-strings.m @@ -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}} diff --git a/clang/test/SemaObjCXX/message.mm b/clang/test/SemaObjCXX/message.mm index f92518ad48c..ab86d9437f0 100644 --- a/clang/test/SemaObjCXX/message.mm +++ b/clang/test/SemaObjCXX/message.mm @@ -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]'}} } diff --git a/clang/test/SemaTemplate/instantiate-expr-4.cpp b/clang/test/SemaTemplate/instantiate-expr-4.cpp index adae1da26aa..11efe5b7f39 100644 --- a/clang/test/SemaTemplate/instantiate-expr-4.cpp +++ b/clang/test/SemaTemplate/instantiate-expr-4.cpp @@ -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'}} } }; diff --git a/clang/test/SemaTemplate/instantiation-default-1.cpp b/clang/test/SemaTemplate/instantiation-default-1.cpp index 6f5a660d99f..99154a5cc46 100644 --- a/clang/test/SemaTemplate/instantiation-default-1.cpp +++ b/clang/test/SemaTemplate/instantiation-default-1.cpp @@ -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; |