summaryrefslogtreecommitdiff
path: root/test/FixIt
diff options
context:
space:
mode:
Diffstat (limited to 'test/FixIt')
-rw-r--r--test/FixIt/fixit-autoreleasepool.m9
-rw-r--r--test/FixIt/fixit-cxx0x.cpp14
-rw-r--r--test/FixIt/fixit-include.c13
-rw-r--r--test/FixIt/fixit-include.h1
-rw-r--r--test/FixIt/fixit-interface-as-param.m11
-rw-r--r--test/FixIt/fixit-objc-message-comma-separator.m17
-rw-r--r--test/FixIt/fixit-unicode.c33
-rw-r--r--test/FixIt/fixit-vexing-parse.cpp51
-rw-r--r--test/FixIt/fixit.c8
-rw-r--r--test/FixIt/fixit.cpp90
-rw-r--r--test/FixIt/format-no-fixit.m30
-rw-r--r--test/FixIt/format.m95
-rw-r--r--test/FixIt/messages.cpp13
-rw-r--r--test/FixIt/objc-literals.m16
14 files changed, 376 insertions, 25 deletions
diff --git a/test/FixIt/fixit-autoreleasepool.m b/test/FixIt/fixit-autoreleasepool.m
new file mode 100644
index 0000000000000..ba1ad130f22a9
--- /dev/null
+++ b/test/FixIt/fixit-autoreleasepool.m
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fdiagnostics-parseable-fixits -x objective-c %s 2>&1 | FileCheck %s
+// rdar://10723084
+
+void f0() {
+ @autorelease {
+ }
+}
+
+// CHECK: {5:4-5:15}:"autoreleasepool"
diff --git a/test/FixIt/fixit-cxx0x.cpp b/test/FixIt/fixit-cxx0x.cpp
index b6cc2c08b0312..0c837b4beb020 100644
--- a/test/FixIt/fixit-cxx0x.cpp
+++ b/test/FixIt/fixit-cxx0x.cpp
@@ -108,3 +108,17 @@ void func();
template<int *ip> struct IP { }; // expected-note{{declared here}}
IP<0> ip0; // expected-error{{null non-type template argument must be cast to template parameter type 'int *'}}
+namespace MissingSemi {
+ struct a // expected-error {{expected ';' after struct}}
+ struct b // expected-error {{expected ';' after struct}}
+ enum x : int { x1, x2, x3 } // expected-error {{expected ';' after enum}}
+ struct c // expected-error {{expected ';' after struct}}
+ enum x : int // expected-error {{expected ';' after enum}}
+ // FIXME: The following gives a poor diagnostic (we parse the 'int' and the
+ // 'struct' as part of the same enum-base.
+ // enum x : int
+ // struct y
+ namespace N {
+ struct d // expected-error {{expected ';' after struct}}
+ }
+}
diff --git a/test/FixIt/fixit-include.c b/test/FixIt/fixit-include.c
new file mode 100644
index 0000000000000..51bd9b0dfd504
--- /dev/null
+++ b/test/FixIt/fixit-include.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -Wall -pedantic -verify %s
+// RUN: cp %s %t
+// RUN: cp %S/fixit-include.h %T
+// RUN: not %clang_cc1 -fsyntax-only -fixit %t
+// RUN: %clang_cc1 -Wall -pedantic %t
+
+#include <fixit-include.h> // expected-error {{'fixit-include.h' file not found with <angled> include; use "quotes" instead}}
+
+#pragma does_not_exist // expected-warning {{unknown pragma ignored}}
+
+int main( void ) {
+ return 0;
+}
diff --git a/test/FixIt/fixit-include.h b/test/FixIt/fixit-include.h
new file mode 100644
index 0000000000000..6a22d2e88eb3f
--- /dev/null
+++ b/test/FixIt/fixit-include.h
@@ -0,0 +1 @@
+// This file is purposefully left empty
diff --git a/test/FixIt/fixit-interface-as-param.m b/test/FixIt/fixit-interface-as-param.m
new file mode 100644
index 0000000000000..3295c82c31a15
--- /dev/null
+++ b/test/FixIt/fixit-interface-as-param.m
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fdiagnostics-parseable-fixits -x objective-c %s 2>&1 | FileCheck %s
+// rdar://11311333
+
+@interface NSView @end
+
+@interface INTF
+- (void) drawRect : inView:(NSView)view;
+@end
+
+// CHECK: {7:35-7:35}:"*"
+
diff --git a/test/FixIt/fixit-objc-message-comma-separator.m b/test/FixIt/fixit-objc-message-comma-separator.m
new file mode 100644
index 0000000000000..0caa33eb0ad27
--- /dev/null
+++ b/test/FixIt/fixit-objc-message-comma-separator.m
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fdiagnostics-parseable-fixits -x objective-c %s 2>&1 | FileCheck %s
+// rdar://11376372
+
+@class NSObject;
+
+@interface TestObj {
+}
+-(void)aMethodWithArg1:(NSObject*)arg1 arg2:(NSObject*)arg2;
+@end
+
+int main(int argc, char *argv[])
+{
+ TestObj *obj;
+ [obj aMethodWithArg1:@"Arg 1 Good", arg2:@"Arg 2 Good"];
+}
+
+// CHECK: {14:39-14:40}:""
diff --git a/test/FixIt/fixit-unicode.c b/test/FixIt/fixit-unicode.c
new file mode 100644
index 0000000000000..2af5e08faa41f
--- /dev/null
+++ b/test/FixIt/fixit-unicode.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck -strict-whitespace %s
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck -check-prefix=CHECK-MACHINE %s
+
+struct Foo {
+ int bar;
+};
+
+// PR13312
+void test1() {
+ struct Foo foo;
+ (&foo)☃>bar = 42;
+// CHECK: error: expected ';' after expression
+// Make sure we emit the fixit right in front of the snowman.
+// CHECK: {{^ \^}}
+// CHECK: {{^ ;}}
+
+// CHECK-MACHINE: fix-it:"{{.*}}fixit-unicode.c":{11:9-11:9}:";"
+}
+
+
+int printf(const char *, ...);
+void test2() {
+ printf("∆: %d", 1L);
+// CHECK: warning: format specifies type 'int' but the argument has type 'long'
+// Don't crash emitting a fixit after the delta.
+// CHECK: printf("
+// CHECK: : %d", 1L);
+// Unfortunately, we can't actually check the location of the printed fixit,
+// because different systems will render the delta differently (either as a
+// character, or as <U+2206>.) The fixit should line up with the %d regardless.
+
+// CHECK-MACHINE: fix-it:"{{.*}}fixit-unicode.c":{23:16-23:18}:"%ld"
+}
diff --git a/test/FixIt/fixit-vexing-parse.cpp b/test/FixIt/fixit-vexing-parse.cpp
index 8450590c67f9c..dd0f87304a537 100644
--- a/test/FixIt/fixit-vexing-parse.cpp
+++ b/test/FixIt/fixit-vexing-parse.cpp
@@ -7,6 +7,7 @@ struct S {
struct T {
T();
+ T(S, S);
int n;
};
@@ -30,26 +31,44 @@ S F2();
namespace N {
void test() {
- // CHECK: fix-it:"{{.*}}":{34:9-34:11}:" = {}"
+ // CHECK: fix-it:"{{.*}}":{35:9-35:11}:" = {}"
S s1(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
- // CHECK: fix-it:"{{.*}}":{38:9-38:10}:";"
- // CHECK: fix-it:"{{.*}}":{39:7-39:9}:" = {}"
+ // CHECK: fix-it:"{{.*}}":{39:9-39:10}:";"
+ // CHECK: fix-it:"{{.*}}":{40:7-40:9}:" = {}"
S s2, // expected-note {{change this ',' to a ';' to call 'F2'}}
F2(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
- // CHECK: fix-it:"{{.*}}":{43:9-43:11}:""
// CHECK: fix-it:"{{.*}}":{44:9-44:11}:""
+ // CHECK: fix-it:"{{.*}}":{45:9-45:11}:""
T t1(), // expected-warning {{function declaration}} expected-note {{remove parentheses}}
t2(); // expected-warning {{function declaration}} expected-note {{remove parentheses}}
- // CHECK: fix-it:"{{.*}}":{47:8-47:10}:" = {}"
+ // Suggest parentheses only around the first argument.
+ // CHECK: fix-it:"{{.*}}":{50:10-50:10}:"("
+ // CHECK: fix-it:"{{.*}}":{50:13-50:13}:")"
+ T t3(S(), S()); // expected-warning {{disambiguated as a function declaration}} expected-note {{add a pair of parentheses}}
+
+ // Check fixit position for pathological case
+ // CHECK: fix-it:"{{.*}}":{56:11-56:11}:"("
+ // CHECK: fix-it:"{{.*}}":{56:20-56:20}:")"
+ float k[1];
+ int l(int(k[0])); // expected-warning {{disambiguated as a function declaration}} expected-note {{add a pair of parentheses}}
+
+ // Don't emit warning and fixit because this must be a function declaration due to void return type.
+ typedef void VO;
+ VO m(int (*p)[4]);
+
+ // Don't emit warning and fixit because direct initializer is not permitted here.
+ if (int n(int())){} // expected-error {{function type is not allowed here}} expected-error {{condition must have an initializer}}
+
+ // CHECK: fix-it:"{{.*}}":{66:8-66:10}:" = {}"
U u(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
- // CHECK: fix-it:"{{.*}}":{50:8-50:10}:""
+ // CHECK: fix-it:"{{.*}}":{69:8-69:10}:""
V v(); // expected-warning {{function declaration}} expected-note {{remove parentheses}}
- // CHECK: fix-it:"{{.*}}":{53:8-53:10}:""
+ // CHECK: fix-it:"{{.*}}":{72:8-72:10}:""
W w(); // expected-warning {{function declaration}} expected-note {{remove parentheses}}
// TODO: Removing the parens here would not initialize U::n.
@@ -57,33 +76,33 @@ namespace N {
// Maybe suggest removing the parens anyway?
X x(); // expected-warning {{function declaration}}
- // CHECK: fix-it:"{{.*}}":{61:11-61:13}:" = 0"
+ // CHECK: fix-it:"{{.*}}":{80:11-80:13}:" = 0"
int n1(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
- // CHECK: fix-it:"{{.*}}":{65:11-65:12}:";"
- // CHECK: fix-it:"{{.*}}":{66:7-66:9}:" = 0"
+ // CHECK: fix-it:"{{.*}}":{84:11-84:12}:";"
+ // CHECK: fix-it:"{{.*}}":{85:7-85:9}:" = 0"
int n2, // expected-note {{change this ',' to a ';' to call 'F1'}}
F1(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
- // CHECK: fix-it:"{{.*}}":{69:13-69:15}:" = 0.0"
+ // CHECK: fix-it:"{{.*}}":{88:13-88:15}:" = 0.0"
double d(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
typedef void *Ptr;
- // CHECK: fix-it:"{{.*}}":{74:10-74:12}:" = 0"
+ // CHECK: fix-it:"{{.*}}":{93:10-93:12}:" = 0"
Ptr p(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
#define NULL 0
- // CHECK: fix-it:"{{.*}}":{78:10-78:12}:" = NULL"
+ // CHECK: fix-it:"{{.*}}":{97:10-97:12}:" = NULL"
Ptr p(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
- // CHECK: fix-it:"{{.*}}":{81:11-81:13}:" = false"
+ // CHECK: fix-it:"{{.*}}":{100:11-100:13}:" = false"
bool b(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
- // CHECK: fix-it:"{{.*}}":{84:11-84:13}:" = '\\0'"
+ // CHECK: fix-it:"{{.*}}":{103:11-103:13}:" = '\\0'"
char c(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
- // CHECK: fix-it:"{{.*}}":{87:15-87:17}:" = L'\\0'"
+ // CHECK: fix-it:"{{.*}}":{106:15-106:17}:" = L'\\0'"
wchar_t wc(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
}
}
diff --git a/test/FixIt/fixit.c b/test/FixIt/fixit.c
index 5e4947b8cdd69..ce6f1092df197 100644
--- a/test/FixIt/fixit.c
+++ b/test/FixIt/fixit.c
@@ -100,3 +100,11 @@ int noSemiAfterLabel(int n) {
}
return 1;
}
+
+struct noSemiAfterStruct // expected-error {{expected ';' after struct}}
+struct noSemiAfterStruct {
+ int n // expected-warning {{';'}}
+} // expected-error {{expected ';' after struct}}
+enum noSemiAfterEnum {
+ e1
+} // expected-error {{expected ';' after enum}}
diff --git a/test/FixIt/fixit.cpp b/test/FixIt/fixit.cpp
index 7d531a537a354..3eac434a36bd3 100644
--- a/test/FixIt/fixit.cpp
+++ b/test/FixIt/fixit.cpp
@@ -54,7 +54,7 @@ namespace rdar7853795 {
}
namespace rdar7796492 {
- class A { int x, y; A(); };
+ struct A { int x, y; A(); };
A::A()
: x(1) y(2) { // expected-error{{missing ',' between base or member initializers}}
@@ -204,3 +204,91 @@ template<template<typename> Foo, // expected-error {{template template parameter
template<typename> typename Bar, // expected-error {{template template parameter requires 'class' after the parameter list}}
template<typename> struct Baz> // expected-error {{template template parameter requires 'class' after the parameter list}}
void func();
+
+namespace ShadowedTagType {
+class Foo {
+ public:
+ enum Bar { X, Y };
+ void SetBar(Bar bar);
+ Bar Bar(); // expected-note 2 {{enum 'Bar' is hidden by a non-type declaration of 'Bar' here}}
+ private:
+ Bar bar_; // expected-error {{must use 'enum' tag to refer to type 'Bar' in this scope}}
+};
+void Foo::SetBar(Bar bar) { bar_ = bar; } // expected-error {{must use 'enum' tag to refer to type 'Bar' in this scope}}
+}
+
+#define NULL __null
+char c = NULL; // expected-warning {{implicit conversion of NULL constant to 'char'}}
+double dbl = NULL; // expected-warning {{implicit conversion of NULL constant to 'double'}}
+
+namespace arrow_suggest {
+
+template <typename T>
+class wrapped_ptr {
+ public:
+ wrapped_ptr(T* ptr) : ptr_(ptr) {}
+ T* operator->() { return ptr_; }
+ private:
+ T *ptr_;
+};
+
+class Worker {
+ public:
+ void DoSomething();
+};
+
+void test() {
+ wrapped_ptr<Worker> worker(new Worker);
+ worker.DoSomething(); // expected-error {{no member named 'DoSomething' in 'arrow_suggest::wrapped_ptr<arrow_suggest::Worker>'; did you mean to use '->' instead of '.'?}}
+}
+
+} // namespace arrow_suggest
+
+// Make sure fixing namespace-qualified identifiers functions properly with
+// namespace-aware typo correction/
+namespace redecl_typo {
+namespace Foo {
+ void BeEvil(); // expected-note {{'BeEvil' declared here}}
+}
+namespace Bar {
+ namespace Foo {
+ bool isGood(); // expected-note {{'Bar::Foo::isGood' declared here}}
+ void beEvil();
+ }
+}
+bool Foo::isGood() { // expected-error {{out-of-line definition of 'isGood' does not match any declaration in namespace 'redecl_typo::Foo'; did you mean 'Bar::Foo::isGood'?}}
+ return true;
+}
+void Foo::beEvil() {} // expected-error {{out-of-line definition of 'beEvil' does not match any declaration in namespace 'redecl_typo::Foo'; did you mean 'BeEvil'?}}
+}
+
+// Test behavior when a template-id is ended by a token which starts with '>'.
+namespace greatergreater {
+ template<typename T> struct S { S(); S(T); };
+ void f(S<int>=0); // expected-error {{a space is required between a right angle bracket and an equals sign (use '> =')}}
+
+ // FIXME: The fix-its here overlap so -fixit mode can't apply the second one.
+ //void f(S<S<int>>=S<int>());
+
+ struct Shr {
+ template<typename T> Shr(T);
+ template<typename T> void operator >>=(T);
+ };
+
+ template<template<typename>> struct TemplateTemplateParam; // expected-error {{requires 'class'}}
+
+ template<typename T> void t();
+ void g() {
+ void (*p)() = &t<int>;
+ (void)(&t<int>==p); // expected-error {{use '> ='}}
+ (void)(&t<int>>=p); // expected-error {{use '> >'}}
+ (void)(&t<S<int>>>=p); // expected-error {{use '> >'}}
+ (Shr)&t<S<int>>>>=p; // expected-error {{use '> >'}}
+
+ // FIXME: We correct this to '&t<int> > >= p;' not '&t<int> >>= p;'
+ //(Shr)&t<int>>>=p;
+
+ // FIXME: The fix-its here overlap.
+ //(void)(&t<S<int>>==p);
+ }
+}
diff --git a/test/FixIt/format-no-fixit.m b/test/FixIt/format-no-fixit.m
new file mode 100644
index 0000000000000..36ecd3f26c012
--- /dev/null
+++ b/test/FixIt/format-no-fixit.m
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fdiagnostics-parseable-fixits -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK-NOT: fix-it:
+
+@class NSString;
+extern void NSLog(NSString *format, ...);
+int printf(const char * restrict, ...) ;
+
+
+void test_object_correction (id x) {
+ printf("%d", x); // expected-warning{{format specifies type 'int' but the argument has type 'id'}}
+ printf("%s", x); // expected-warning{{format specifies type 'char *' but the argument has type 'id'}}
+ printf("%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'id'}}
+}
+
+
+// Old-style Core Foundation types do not have __attribute__((NSObject)).
+// This is okay, but we won't suggest a fixit; arbitrary structure pointers may
+// not be objects.
+typedef const struct __CFString * CFStringRef;
+
+void test_cf_object_correction (CFStringRef x) {
+ NSLog(@"%@", x); // no-warning
+
+ NSLog(@"%d", x); // expected-warning{{format specifies type 'int' but the argument has type 'CFStringRef'}}
+ NSLog(@"%s", x); // expected-warning{{format specifies type 'char *' but the argument has type 'CFStringRef'}}
+ NSLog(@"%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'CFStringRef'}}
+}
+
diff --git a/test/FixIt/format.m b/test/FixIt/format.m
new file mode 100644
index 0000000000000..c4747019b2df6
--- /dev/null
+++ b/test/FixIt/format.m
@@ -0,0 +1,95 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s
+// RUN: %clang_cc1 -fdiagnostics-parseable-fixits -fblocks %s 2>&1 | FileCheck %s
+
+@class NSString;
+extern void NSLog(NSString *, ...);
+int printf(const char * restrict, ...) ;
+
+void test_integer_correction (int x) {
+ printf("%d", x); // no-warning
+ printf("%s", x); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
+ printf("%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'int'}}
+ // CHECK: fix-it:"{{.*}}":{10:11-10:13}:"%d"
+ // CHECK: fix-it:"{{.*}}":{11:11-11:14}:"%d"
+
+ NSLog(@"%d", x); // no-warning
+ NSLog(@"%s", x); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
+ NSLog(@"%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'int'}}
+ NSLog(@"%@", x); // expected-warning{{format specifies type 'id' but the argument has type 'int'}}
+ // CHECK: fix-it:"{{.*}}":{16:11-16:13}:"%d"
+ // CHECK: fix-it:"{{.*}}":{17:11-17:14}:"%d"
+ // CHECK: fix-it:"{{.*}}":{18:11-18:13}:"%d"
+}
+
+void test_string_correction (char *x) {
+ printf("%d", x); // expected-warning{{format specifies type 'int' but the argument has type 'char *'}}
+ printf("%s", x); // no-warning
+ printf("%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'char *'}}
+ // CHECK: fix-it:"{{.*}}":{25:11-25:13}:"%s"
+ // CHECK: fix-it:"{{.*}}":{27:11-27:14}:"%s"
+
+ NSLog(@"%d", x); // expected-warning{{format specifies type 'int' but the argument has type 'char *'}}
+ NSLog(@"%s", x); // no-warning
+ NSLog(@"%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'char *'}}
+ NSLog(@"%@", x); // expected-warning{{format specifies type 'id' but the argument has type 'char *'}}
+ // CHECK: fix-it:"{{.*}}":{31:11-31:13}:"%s"
+ // CHECK: fix-it:"{{.*}}":{33:11-33:14}:"%s"
+ // CHECK: fix-it:"{{.*}}":{34:11-34:13}:"%s"
+}
+
+void test_object_correction (id x) {
+ NSLog(@"%d", x); // expected-warning{{format specifies type 'int' but the argument has type 'id'}}
+ NSLog(@"%s", x); // expected-warning{{format specifies type 'char *' but the argument has type 'id'}}
+ NSLog(@"%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'id'}}
+ NSLog(@"%@", x); // no-warning
+ // CHECK: fix-it:"{{.*}}":{41:11-41:13}:"%@"
+ // CHECK: fix-it:"{{.*}}":{42:11-42:13}:"%@"
+ // CHECK: fix-it:"{{.*}}":{43:11-43:14}:"%@"
+}
+
+typedef const struct __CFString * __attribute__((NSObject)) CFStringRef;
+void test_cf_object_correction (CFStringRef x) {
+ NSLog(@"%d", x); // expected-warning{{format specifies type 'int' but the argument has type 'CFStringRef'}}
+ NSLog(@"%s", x); // expected-warning{{format specifies type 'char *' but the argument has type 'CFStringRef'}}
+ NSLog(@"%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'CFStringRef'}}
+ NSLog(@"%@", x); // no-warning
+ // CHECK: fix-it:"{{.*}}":{52:11-52:13}:"%@"
+ // CHECK: fix-it:"{{.*}}":{53:11-53:13}:"%@"
+ // CHECK: fix-it:"{{.*}}":{54:11-54:14}:"%@"
+}
+
+typedef void (^block_t)(void);
+void test_block_correction (block_t x) {
+ NSLog(@"%d", x); // expected-warning{{format specifies type 'int' but the argument has type 'block_t'}}
+ NSLog(@"%s", x); // expected-warning{{format specifies type 'char *' but the argument has type 'block_t'}}
+ NSLog(@"%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'block_t'}}
+ NSLog(@"%@", x); // no-warning
+ // CHECK: fix-it:"{{.*}}":{63:11-63:13}:"%@"
+ // CHECK: fix-it:"{{.*}}":{64:11-64:13}:"%@"
+ // CHECK: fix-it:"{{.*}}":{65:11-65:14}:"%@"
+}
+
+void test_class_correction (Class x) {
+ NSLog(@"%d", x); // expected-warning{{format specifies type 'int' but the argument has type 'Class'}}
+ NSLog(@"%s", x); // expected-warning{{format specifies type 'char *' but the argument has type 'Class'}}
+ NSLog(@"%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'Class'}}
+ NSLog(@"%@", x); // no-warning
+ // CHECK: fix-it:"{{.*}}":{73:11-73:13}:"%@"
+ // CHECK: fix-it:"{{.*}}":{74:11-74:13}:"%@"
+ // CHECK: fix-it:"{{.*}}":{75:11-75:14}:"%@"
+}
+
+
+typedef enum : int { NSUTF8StringEncoding = 8 } NSStringEncoding;
+void test_fixed_enum_correction(NSStringEncoding x) {
+ NSLog(@"%@", x); // expected-warning{{format specifies type 'id' but the argument has type 'NSStringEncoding'}}
+ // CHECK: fix-it:"{{.*}}":{85:11-85:13}:"%d"
+}
+
+typedef __SIZE_TYPE__ size_t;
+enum SomeSize : size_t { IntegerSize = sizeof(int) };
+void test_named_fixed_enum_correction(enum SomeSize x) {
+ NSLog(@"%@", x); // expected-warning{{format specifies type 'id' but the argument has type 'enum SomeSize'}}
+ // CHECK: fix-it:"{{.*}}":{92:11-92:13}:"%zu"
+}
+
diff --git a/test/FixIt/messages.cpp b/test/FixIt/messages.cpp
new file mode 100644
index 0000000000000..b9391449ad16b
--- /dev/null
+++ b/test/FixIt/messages.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 2>&1 %s | FileCheck -strict-whitespace %s
+
+struct A {
+ unsigned int a;
+};
+
+// PR10696
+void testOverlappingInsertions(int b) {
+ A var = { b };
+ // CHECK: A var = { b };
+ // CHECK: ^
+ // CHECK: static_cast<unsigned int>( )
+}
diff --git a/test/FixIt/objc-literals.m b/test/FixIt/objc-literals.m
index 03d64b156496b..549cfde20250a 100644
--- a/test/FixIt/objc-literals.m
+++ b/test/FixIt/objc-literals.m
@@ -2,13 +2,13 @@
// RUN: cp %s %t
// RUN: not %clang_cc1 -fsyntax-only -fixit -x objective-c %t
// RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x objective-c %t
-// RUN: grep arrayWithObjects %t
typedef unsigned char BOOL;
-@interface NSNumber @end
+@interface NSObject
+@end
-@interface NSNumber (NSNumberCreation)
+@interface NSNumber : NSObject
+ (NSNumber *)numberWithChar:(char)value;
+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
+ (NSNumber *)numberWithShort:(short)value;
@@ -24,17 +24,17 @@ typedef unsigned char BOOL;
+ (NSNumber *)numberWithBool:(BOOL)value;
@end
-@interface NSArray
-@end
-
-@interface NSArray (NSArrayCreation)
+@interface NSArray : NSObject
+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
@end
-@interface NSDictionary
+@interface NSDictionary : NSObject
+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
@end
+@interface NSString : NSObject
+@end
+
void fixes() {
id arr = @[
17, // expected-error{{numeric literal must be prefixed by '@' in a collection}}