diff options
Diffstat (limited to 'test/FixIt')
-rw-r--r-- | test/FixIt/fixit-errors.c | 2 | ||||
-rw-r--r-- | test/FixIt/fixit-objc-message.m | 38 | ||||
-rw-r--r-- | test/FixIt/fixit-objc.m | 32 | ||||
-rw-r--r-- | test/FixIt/fixit-unrecoverable.cpp | 3 | ||||
-rw-r--r-- | test/FixIt/fixit.c | 7 | ||||
-rw-r--r-- | test/FixIt/fixit.cpp | 27 | ||||
-rw-r--r-- | test/FixIt/typo.cpp | 1 | ||||
-rw-r--r-- | test/FixIt/typo.m | 25 |
8 files changed, 115 insertions, 20 deletions
diff --git a/test/FixIt/fixit-errors.c b/test/FixIt/fixit-errors.c index ff06363..f8e2295 100644 --- a/test/FixIt/fixit-errors.c +++ b/test/FixIt/fixit-errors.c @@ -1,5 +1,5 @@ // RUN: cp %s %t -// RUN: %clang_cc1 -pedantic -verify -fixit -x c %t || true +// RUN: true || %clang_cc1 -pedantic -verify -fixit -x c %t // RUN: %clang_cc1 -pedantic -Werror -x c %t // XFAIL: * diff --git a/test/FixIt/fixit-objc-message.m b/test/FixIt/fixit-objc-message.m new file mode 100644 index 0000000..1fef3cc --- /dev/null +++ b/test/FixIt/fixit-objc-message.m @@ -0,0 +1,38 @@ +// Objective-C recovery +// RUN: cp %s %t +// RUN: %clang_cc1 -pedantic -Wall -fixit -x objective-c %t || true +// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -x objective-c %t + +// Objective-C++ recovery +// RUN: cp %s %t +// RUN: %clang_cc1 -pedantic -Wall -fixit -x objective-c++ %t || true +// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -x objective-c++ %t + +@interface A +- (int)method1:(int)x second:(float)y; ++ (int)method2:(int)x second:(double)y; +- (int)getBlah; +@end + +void f(A *a, int i, int j) { + a method1:5+2 second:+(3.14159)]; + a method1:[a method1:3 second:j] second:i++] + a getBlah]; + + int array[17]; + (void)array[a method1:5+2 second:+(3.14159)]]; + (A method2:5+2 second:3.14159]); + A method2:5+2 second:3.14159] + if (A method2:5+2 second:3.14159]) { } +} + +@interface B : A +- (int)method1:(int)x second:(float)y; +@end + +@implementation B +- (int)method1:(int)x second:(float)y { + super method1:x second:y]; + return super getBlah]; +} +@end diff --git a/test/FixIt/fixit-objc.m b/test/FixIt/fixit-objc.m index 03f28a1..bf704c6 100644 --- a/test/FixIt/fixit-objc.m +++ b/test/FixIt/fixit-objc.m @@ -1,6 +1,7 @@ +// RUN: %clang_cc1 -pedantic -verify %s // RUN: cp %s %t -// RUN: %clang_cc1 -pedantic -fixit -x objective-c %t -// RUN: %clang_cc1 -pedantic -verify -x objective-c %t +// RUN: not %clang_cc1 -pedantic -fixit -x objective-c %t +// RUN: %clang_cc1 -pedantic -Werror -x objective-c %t /* This is a test of the various code modification hints that are provided as part of warning or extension diagnostics. All of the @@ -10,28 +11,31 @@ @protocol X; void foo() { - <X> *P; // should be fixed to 'id<X>'. + <X> *P; // expected-warning{{protocol qualifiers without 'id' is archaic}} } @class A; @class NSString; @interface Test -- (void)test:(NSString *)string; +- (void)test:(NSString *)string; // expected-note{{passing argument to parameter 'string' here}} @property (copy) NSString *property; @end -void g(NSString *a); -void h(id a); +void g(NSString *a); // expected-note{{passing argument to parameter 'a' here}} +void h(id a); // expected-note 2{{passing argument to parameter 'a' here}} void f(Test *t) { - NSString *a = "Foo"; - id b = "Foo"; - A* c = "Foo"; // expected-warning {{incompatible pointer types initializing 'A *' with an expression of type 'char [4]'}} - g("Foo"); - h("Foo"); - h(("Foo")); - [t test:"Foo"]; - t.property = "Foo"; + NSString *a = "Foo"; // expected-warning {{incompatible pointer types initializing 'NSString *' with an expression of type 'char [4]'}} + id b = "Foo"; // expected-warning {{incompatible pointer types initializing 'id' with an expression of type 'char [4]'}} + g("Foo"); // expected-warning{{incompatible pointer types passing 'char [4]' to parameter of type 'NSString *'}} + h("Foo"); // expected-warning{{incompatible pointer types passing 'char [4]' to parameter of type 'id'}} + h(("Foo")); // expected-warning{{incompatible pointer types passing 'char [4]' to parameter of type 'id'}} + [t test:"Foo"]; // expected-warning{{incompatible pointer types sending 'char [4]' to parameter of type 'NSString *'}} + t.property = "Foo"; // expected-warning{{incompatible pointer types assigning to 'NSString *' from 'char [4]'}} + + // <rdar://problem/6896493> + [t test:@"Foo"]]; // expected-error{{extraneous ']' before ';'}} + g(@"Foo")); // expected-error{{extraneous ')' before ';'}} } diff --git a/test/FixIt/fixit-unrecoverable.cpp b/test/FixIt/fixit-unrecoverable.cpp index 00ed897..1e1f1b8 100644 --- a/test/FixIt/fixit-unrecoverable.cpp +++ b/test/FixIt/fixit-unrecoverable.cpp @@ -6,6 +6,7 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s float f(int y) { - return static_cst<float>(y); // expected-error{{use of undeclared identifier 'static_cst'; did you mean 'static_cast'?}} + return static_cst<float>(y); // expected-error{{use of undeclared identifier 'static_cst'; did you mean 'static_cast'?}} \ + // expected-error{{for function-style cast or type construction}} } diff --git a/test/FixIt/fixit.c b/test/FixIt/fixit.c index 890fb10..9c74435 100644 --- a/test/FixIt/fixit.c +++ b/test/FixIt/fixit.c @@ -41,3 +41,10 @@ int test_cond(int y, int fooBar) { // CHECK: typedef int int_t; typedef typedef int int_t; + +// <rdar://problem/7159693> +enum Color { + Red // expected-error{{missing ',' between enumerators}} + Green = 17 // expected-error{{missing ',' between enumerators}} + Blue, +}; diff --git a/test/FixIt/fixit.cpp b/test/FixIt/fixit.cpp index b9282c4..41b187b 100644 --- a/test/FixIt/fixit.cpp +++ b/test/FixIt/fixit.cpp @@ -51,3 +51,30 @@ namespace rdar7853795 { } }; } + +namespace rdar7796492 { + class A { int x, y; A(); }; + + A::A() + : x(1) y(2) { // expected-error{{missing ',' between base or member initializers}} + } + +} + +// extra qualification on member +class C { + int C::foo(); +}; + +namespace rdar8488464 { +int x == 0; // expected-error {{invalid '==' at end of declaration; did you mean '='?}} + +void f() { + int x == 0; // expected-error {{invalid '==' at end of declaration; did you mean '='?}} + (void)x; + if (int x == 0) { // expected-error {{invalid '==' at end of declaration; did you mean '='?}} + (void)x; + } +} +} + diff --git a/test/FixIt/typo.cpp b/test/FixIt/typo.cpp index 077aa9c..d1e732f 100644 --- a/test/FixIt/typo.cpp +++ b/test/FixIt/typo.cpp @@ -2,6 +2,7 @@ // RUN: cp %s %t // RUN: %clang_cc1 -fsyntax-only -fixit -x c++ %t || true // RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x c++ %t + namespace std { template<typename T> class basic_string { // expected-note 2{{'basic_string' declared here}} public: diff --git a/test/FixIt/typo.m b/test/FixIt/typo.m index 6853ab6..8a474ab 100644 --- a/test/FixIt/typo.m +++ b/test/FixIt/typo.m @@ -1,7 +1,10 @@ // RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -DNON_FIXITS -verify %s -// RUN: %clang -E -P %s -o %t -// RUN: %clang_cc1 -x objective-c -fsyntax-only -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fixit %t || true -// RUN: %clang_cc1 -x objective-c -fsyntax-only -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -pedantic -Werror %t +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -x objective-c -E -P %s -o %t +// RUN: %clang_cc1 -x objective-c -fsyntax-only -fobjc-nonfragile-abi -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fixit %t || true +// RUN: %clang_cc1 -x objective-c -fsyntax-only -fobjc-nonfragile-abi -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -pedantic -Werror %t +// RUN: false +// XFAIL: * + @interface NSString // expected-note{{'NSString' declared here}} + (int)method:(int)x; @@ -10,7 +13,8 @@ #ifdef NON_FIXITS void test() { // FIXME: not providing fix-its - NSstring *str = @"A string"; // expected-error{{use of undeclared identifier 'NSstring'; did you mean 'NSString'?}} + NSstring *str = @"A string"; // expected-error{{use of undeclared identifier 'NSstring'; did you mean 'NSString'?}} \ + // expected-error{{use of undeclared identifier 'str'}} } #endif @@ -101,6 +105,7 @@ void test2(Collide *a) { @interface Super - (int)method; // expected-note{{using}} - (int)method2; +- (int)method3:(id)x; @end @interface Sub : Super @@ -154,3 +159,15 @@ void f(A *a) { [A methodA] // expected-error{{expected ';' after expression}} } +#ifdef NON_FIXITS +@interface Sub3 : Super +- (int)method3; +@end + +@implementation Sub3 +- (int)method3 { + int x = super; // expected-note{{use of undeclared identifier 'super'}} + return 0; +} +@end +#endif |