diff options
Diffstat (limited to 'test/FixIt')
27 files changed, 291 insertions, 35 deletions
diff --git a/test/FixIt/bridge-cast-in-arc.mm b/test/FixIt/bridge-cast-in-arc.mm index 5cd482f..d32629d 100644 --- a/test/FixIt/bridge-cast-in-arc.mm +++ b/test/FixIt/bridge-cast-in-arc.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fdiagnostics-parseable-fixits -x objective-c++ -fobjc-arc %s 2>&1 | FileCheck %s +// RUN: not %clang_cc1 -triple x86_64-apple-darwin10 -fdiagnostics-parseable-fixits -x objective-c++ -fobjc-arc %s 2>&1 | FileCheck %s // rdar://12788838 id obj; diff --git a/test/FixIt/fixit-autoreleasepool.m b/test/FixIt/fixit-autoreleasepool.m index ba1ad13..06c4544 100644 --- a/test/FixIt/fixit-autoreleasepool.m +++ b/test/FixIt/fixit-autoreleasepool.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fdiagnostics-parseable-fixits -x objective-c %s 2>&1 | FileCheck %s +// RUN: not %clang_cc1 -triple x86_64-apple-darwin10 -fdiagnostics-parseable-fixits -x objective-c %s 2>&1 | FileCheck %s // rdar://10723084 void f0() { diff --git a/test/FixIt/fixit-cxx0x.cpp b/test/FixIt/fixit-cxx0x.cpp index 1f6275f..bfd8c3d 100644 --- a/test/FixIt/fixit-cxx0x.cpp +++ b/test/FixIt/fixit-cxx0x.cpp @@ -132,3 +132,8 @@ namespace NonStaticConstexpr { } }; } + +int RegisterVariable() { + register int n; // expected-warning {{'register' storage class specifier is deprecated}} + return n; +} diff --git a/test/FixIt/fixit-cxx11-attributes.cpp b/test/FixIt/fixit-cxx11-attributes.cpp index f28bdfc..30697a9 100644 --- a/test/FixIt/fixit-cxx11-attributes.cpp +++ b/test/FixIt/fixit-cxx11-attributes.cpp @@ -2,7 +2,7 @@ // RUN: cp %s %t // RUN: not %clang_cc1 -x c++ -std=c++11 -fixit %t // RUN: %clang_cc1 -Wall -pedantic -x c++ -std=c++11 %t -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s +// RUN: not %clang_cc1 -std=c++11 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s namespace ClassSpecifier { class [[]] [[]] diff --git a/test/FixIt/fixit-errors-1.c b/test/FixIt/fixit-errors-1.c index b034b19..0dbbe19 100644 --- a/test/FixIt/fixit-errors-1.c +++ b/test/FixIt/fixit-errors-1.c @@ -1,6 +1,6 @@ // RUN: cp %s %t // RUN: %clang_cc1 -pedantic -fixit %t -// RUN: echo %clang_cc1 -pedantic -Werror -x c %t +// RUN: %clang_cc1 -pedantic -Werror -x 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 diff --git a/test/FixIt/fixit-include.c b/test/FixIt/fixit-include.c index 383c513..fd5d7a9 100644 --- a/test/FixIt/fixit-include.c +++ b/test/FixIt/fixit-include.c @@ -3,7 +3,7 @@ // RUN: cp %S/fixit-include.h %T // RUN: not %clang_cc1 -fsyntax-only -fixit %t // RUN: %clang_cc1 -Wall -pedantic %t -// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s +// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s #include <fixit-include.h> // expected-error {{'fixit-include.h' file not found with <angled> include; use "quotes" instead}} // CHECK: fix-it:{{.*}}:{8:10-8:27} diff --git a/test/FixIt/fixit-interface-as-param.m b/test/FixIt/fixit-interface-as-param.m index 3295c82..75da572 100644 --- a/test/FixIt/fixit-interface-as-param.m +++ b/test/FixIt/fixit-interface-as-param.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fdiagnostics-parseable-fixits -x objective-c %s 2>&1 | FileCheck %s +// RUN: not %clang_cc1 -triple x86_64-apple-darwin10 -fdiagnostics-parseable-fixits -x objective-c %s 2>&1 | FileCheck %s // rdar://11311333 @interface NSView @end diff --git a/test/FixIt/fixit-objc-message-comma-separator.m b/test/FixIt/fixit-objc-message-comma-separator.m index 0caa33e..748553e 100644 --- a/test/FixIt/fixit-objc-message-comma-separator.m +++ b/test/FixIt/fixit-objc-message-comma-separator.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fdiagnostics-parseable-fixits -x objective-c %s 2>&1 | FileCheck %s +// RUN: not %clang_cc1 -triple x86_64-apple-darwin10 -fdiagnostics-parseable-fixits -x objective-c %s 2>&1 | FileCheck %s // rdar://11376372 @class NSObject; diff --git a/test/FixIt/fixit-objc.m b/test/FixIt/fixit-objc.m index ea57fe6..7c4776a 100644 --- a/test/FixIt/fixit-objc.m +++ b/test/FixIt/fixit-objc.m @@ -27,13 +27,13 @@ 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"; // expected-warning {{incompatible pointer types initializing 'NSString *' with an expression of type 'char [4]'}} + NSString *a = "Foo"; // expected-warning {{string literal must be prefixed by '@'}} 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 *'}} + g("Foo"); // expected-warning {{string literal must be prefixed by '@'}} 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]'}} + [t test:"Foo"]; // expected-warning {{string literal must be prefixed by '@'}} + t.property = "Foo"; // expected-warning {{string literal must be prefixed by '@'}} // <rdar://problem/6896493> [t test:@"Foo"]]; // expected-error{{extraneous ']' before ';'}} diff --git a/test/FixIt/fixit-static-object-decl.m b/test/FixIt/fixit-static-object-decl.m index e13900f..5f4fead 100644 --- a/test/FixIt/fixit-static-object-decl.m +++ b/test/FixIt/fixit-static-object-decl.m @@ -5,8 +5,8 @@ // Objective-C++ recovery // RUN: cp %s %t -// RUN: not %clang_cc1 -fixit -x objective-c++ %t -// RUN: %clang_cc1 -fsyntax-only -Werror -x objective-c++ %t +// RUN: not %clang_cc1 -fixit -x objective-c++ %t -std=c++11 +// RUN: %clang_cc1 -fsyntax-only -Werror -x objective-c++ %t -std=c++11 // rdar://9603056 @interface S @end @@ -24,6 +24,14 @@ NSArray func() { return P; } +NSArray (func2)() { return 0; } + +#ifdef __cplusplus +void test_result_type() { + auto l1 = [] () -> NSArray { return 0; }; +} +#endif + int main() { NSArray pluginNames = [NSArray arrayWithObjects]; } diff --git a/test/FixIt/fixit-unicode-with-utf8-output.c b/test/FixIt/fixit-unicode-with-utf8-output.c new file mode 100644 index 0000000..aff8542 --- /dev/null +++ b/test/FixIt/fixit-unicode-with-utf8-output.c @@ -0,0 +1,24 @@ +// This test is an additional set of checks for the fixit-unicode.c test for +// systems capable of outputting Unicode characters to the standard output in +// the UTF-8 encoding. +// RUN: not %clang_cc1 -fsyntax-only %S/fixit-unicode.c 2>&1 | FileCheck -strict-whitespace %s + +// CHECK: warning: format specifies type 'int' but the argument has type 'long' +// CHECK: {{^ printf\("∆: %d", 1L\);}} +// CHECK: {{^ ~~ \^~}} + +// CHECK: error: use of undeclared identifier 'กsss'; did you mean 'กssss'? +// CHECK: {{^ \^}} +// CHECK: {{^ กssss}} + +// CHECK: error: use of undeclared identifier 'ssกs'; did you mean 'ssกss'? +// CHECK: {{^ \^}} +// CHECK: {{^ ssกss}} + +// CHECK: error: use of undeclared identifier 'ss一二三'; did you mean 's一二三'? +// CHECK: {{^ \^~~~~~~~}} +// CHECK: {{^ s一二三}} + +// CHECK: error: use of undeclared identifier 'sssssssss'; did you mean 'sssssssssก'? +// CHECK: {{^ \^}} +// CHECK: {{^ sssssssssก}} diff --git a/test/FixIt/fixit-unicode.c b/test/FixIt/fixit-unicode.c index 9c0242e..360ac69 100644 --- a/test/FixIt/fixit-unicode.c +++ b/test/FixIt/fixit-unicode.c @@ -1,5 +1,9 @@ -// 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 +// This file contains code and checks, that should work on any platform. +// There's a set of additional checks for systems with proper support of UTF-8 +// on the standard output in fixit-unicode-with-utf8-output.c. + +// RUN: not %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck -strict-whitespace %s +// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck -check-prefix=CHECK-MACHINE %s struct Foo { int bar; @@ -16,8 +20,8 @@ void test1() { // CHECK: {{^ \^}} // CHECK: {{^ ;}} -// CHECK-MACHINE: fix-it:"{{.*}}fixit-unicode.c":{[[@LINE-8]]:15-[[@LINE-8]]:18}:"" -// CHECK-MACHINE: fix-it:"{{.*}}fixit-unicode.c":{[[@LINE-9]]:15-[[@LINE-9]]:15}:";" +// CHECK-MACHINE: fix-it:"{{.*}}":{[[@LINE-8]]:15-[[@LINE-8]]:18}:"" +// CHECK-MACHINE: fix-it:"{{.*}}":{[[@LINE-9]]:15-[[@LINE-9]]:15}:";" } @@ -32,5 +36,30 @@ void test2() { // 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":{[[@LINE-9]]:16-[[@LINE-9]]:18}:"%ld" +// CHECK-MACHINE: fix-it:"{{.*}}":{[[@LINE-9]]:16-[[@LINE-9]]:18}:"%ld" +} + +void test3() { + int กssss = 42; + int a = กsss; // expected-error{{use of undeclared identifier 'กsss'; did you mean 'กssss'?}} +// CHECK: {{^ \^}} +// CHECK: {{^ [^ ]+ssss}} +// CHECK-MACHINE: fix-it:"{{.*}}":{[[@LINE-3]]:11-[[@LINE-3]]:17}:"\340\270\201ssss" + + int ssกss = 42; + int b = ssกs; // expected-error{{use of undeclared identifier 'ssกs'; did you mean 'ssกss'?}} +// CHECK: {{^ \^}} +// CHECK: {{^ ss.+ss}} +// CHECK-MACHINE: fix-it:"{{.*}}":{[[@LINE-3]]:11-[[@LINE-3]]:17}:"ss\340\270\201ss" + + int s一二三 = 42; + int b一二三四五六七 = ss一二三; // expected-error{{use of undeclared identifier 'ss一二三'; did you mean 's一二三'?}} +// CHECK-MACHINE: fix-it:"{{.*}}":{[[@LINE-1]]:32-[[@LINE-1]]:43}:"s\344\270\200\344\272\214\344\270\211" + + + int sssssssssก = 42; + int c = sssssssss; // expected-error{{use of undeclared identifier 'sssssssss'; did you mean 'sssssssssก'?}} +// CHECK: {{^ \^}} +// CHECK: {{^ sssssssss.+}} +// CHECK-MACHINE: fix-it:"{{.*}}":{[[@LINE-3]]:11-[[@LINE-3]]:20}:"sssssssss\340\270\201" } diff --git a/test/FixIt/fixit-uninit.c b/test/FixIt/fixit-uninit.c new file mode 100644 index 0000000..853041e --- /dev/null +++ b/test/FixIt/fixit-uninit.c @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s + +_Bool test_bool_no_false() { + _Bool var; // expected-note {{initialize}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:12-[[@LINE-1]]:12}:" = 0" + return var; // expected-warning {{uninitialized}} +} + +#define bool _Bool +#define false (bool)0 +#define true (bool)1 +bool test_bool_with_false() { + bool var; // expected-note {{initialize}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:11}:" = false" + return var; // expected-warning {{uninitialized}} +} + +bool test_bool_with_false_undefined() { + bool +#undef false + var; // expected-note {{initialize}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:10}:" = 0" + return var; // expected-warning {{uninitialized}} +} diff --git a/test/FixIt/fixit-vexing-parse.cpp b/test/FixIt/fixit-vexing-parse.cpp index dd0f873..79d8cad 100644 --- a/test/FixIt/fixit-vexing-parse.cpp +++ b/test/FixIt/fixit-vexing-parse.cpp @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -verify -x c++ %s -// RUN: %clang_cc1 -fdiagnostics-parseable-fixits -x c++ %s 2>&1 | FileCheck %s +// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits -x c++ %s 2>&1 | FileCheck %s struct S { int n; diff --git a/test/FixIt/fixit.c b/test/FixIt/fixit.c index 00adb19..6443fe5 100644 --- a/test/FixIt/fixit.c +++ b/test/FixIt/fixit.c @@ -115,3 +115,5 @@ struct noSemiAfterStruct { enum noSemiAfterEnum { e1 } // expected-error {{expected ';' after enum}} + +int PR17175 __attribute__((visibility(hidden))); // expected-error {{'visibility' attribute requires a string}} diff --git a/test/FixIt/fixit.cpp b/test/FixIt/fixit.cpp index fca596b..52bbb38 100644 --- a/test/FixIt/fixit.cpp +++ b/test/FixIt/fixit.cpp @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -pedantic -Wall -Wno-comment -verify -fcxx-exceptions -x c++ %s -// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -x c++ %s 2>&1 | FileCheck %s +// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -x c++ %s 2>&1 | FileCheck %s // RUN: cp %s %t // RUN: not %clang_cc1 -pedantic -Wall -Wno-comment -fcxx-exceptions -fixit -x c++ %t // RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -Wno-comment -fcxx-exceptions -x c++ %t @@ -307,3 +307,34 @@ namespace dtor_fixit { // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:6-[[@LINE-1]]:9}:"foo" }; } + +namespace PR5066 { + template<typename T> struct X {}; + X<int *p> x; // expected-error {{type-id cannot have a name}} +} + +namespace PR5898 { + class A { + public: + const char *str(); + }; + const char* foo(A &x) + { + return x.str.(); // expected-error {{unexpected '.' in function call; perhaps remove the '.'?}} + } + bool bar(A x, const char *y) { + return foo->(x) == y; // expected-error {{unexpected '->' in function call; perhaps remove the '->'?}} + } +} + +namespace PR15045 { + class Cl0 { + public: + int a; + }; + + int f() { + Cl0 c; + return c->a; // expected-error {{member reference type 'PR15045::Cl0' is not a pointer; maybe you meant to use '.'?}} + } +} diff --git a/test/FixIt/format.m b/test/FixIt/format.m index 919212b..5e46360 100644 --- a/test/FixIt/format.m +++ b/test/FixIt/format.m @@ -186,26 +186,26 @@ void test_percent_C() { const unsigned short data = 'a'; NSLog(@"%C", data); // no-warning - NSLog(@"%C", 0x2603); // expected-warning{{format specifies type 'unichar' (aka 'unsigned short') but the argument has type 'int'}} + NSLog(@"%C", 0x260300); // expected-warning{{format specifies type 'unichar' (aka 'unsigned short') but the argument has type 'int'}} // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%d" // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:16}:"(unsigned short)" typedef unsigned short unichar; - NSLog(@"%C", 0x2603); // expected-warning{{format specifies type 'unichar' (aka 'unsigned short') but the argument has type 'int'}} + NSLog(@"%C", 0x260300); // expected-warning{{format specifies type 'unichar' (aka 'unsigned short') but the argument has type 'int'}} // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%d" // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:16}:"(unichar)" - NSLog(@"%C", data ? 0x2F : 0x2603); // expected-warning{{format specifies type 'unichar' (aka 'unsigned short') but the argument has type 'int'}} + NSLog(@"%C", data ? 0x2F0000 : 0x260300); // expected-warning{{format specifies type 'unichar' (aka 'unsigned short') but the argument has type 'int'}} // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%d" // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:16}:"(unichar)(" - // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:36-[[@LINE-3]]:36}:")" + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:42-[[@LINE-3]]:42}:")" NSLog(@"%C", 0.0); // expected-warning{{format specifies type 'unichar' (aka 'unsigned short') but the argument has type 'double'}} // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%f" // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:16}:"(unichar)" - NSLog(@"%C", (char)0x2603); // expected-warning{{format specifies type 'unichar' (aka 'unsigned short') but the argument has type 'char'}} + NSLog(@"%C", (char)0x260300); // expected-warning{{format specifies type 'unichar' (aka 'unsigned short') but the argument has type 'char'}} // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%c" // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:22}:"(unichar)" diff --git a/test/FixIt/format.mm b/test/FixIt/format.mm index 64c6c47..9d89c06 100644 --- a/test/FixIt/format.mm +++ b/test/FixIt/format.mm @@ -11,7 +11,7 @@ void test_percent_C() { NSLog(@"%C", wchar_data); // expected-warning{{format specifies type 'unichar' (aka 'unsigned short') but the argument has type 'wchar_t'}} // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:16-[[@LINE-1]]:16}:"(unsigned short)" - NSLog(@"%C", 0x2603); // expected-warning{{format specifies type 'unichar' (aka 'unsigned short') but the argument has type 'int'}} + NSLog(@"%C", 0x260300); // expected-warning{{format specifies type 'unichar' (aka 'unsigned short') but the argument has type 'int'}} // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%d" // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:16}:"(unsigned short)" @@ -20,7 +20,7 @@ void test_percent_C() { NSLog(@"%C", wchar_data); // expected-warning{{format specifies type 'unichar' (aka 'unsigned short') but the argument has type 'wchar_t'}} // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:16-[[@LINE-1]]:16}:"(unichar)" - NSLog(@"%C", 0x2603); // expected-warning{{format specifies type 'unichar' (aka 'unsigned short') but the argument has type 'int'}} + NSLog(@"%C", 0x260300); // expected-warning{{format specifies type 'unichar' (aka 'unsigned short') but the argument has type 'int'}} // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%d" // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:16}:"(unichar)" diff --git a/test/FixIt/lit.local.cfg b/test/FixIt/lit.local.cfg new file mode 100644 index 0000000..5bbc711 --- /dev/null +++ b/test/FixIt/lit.local.cfg @@ -0,0 +1,2 @@ +if config.root.clang_rewriter == 0: + config.unsupported = True diff --git a/test/FixIt/messages.cpp b/test/FixIt/messages.cpp index b939144..eb4c09d 100644 --- a/test/FixIt/messages.cpp +++ b/test/FixIt/messages.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 2>&1 %s | FileCheck -strict-whitespace %s +// RUN: not %clang_cc1 -fsyntax-only -std=c++11 2>&1 %s | FileCheck -strict-whitespace %s struct A { unsigned int a; diff --git a/test/FixIt/no-fixit.cpp b/test/FixIt/no-fixit.cpp index 9da2922..7e8e1fb 100644 --- a/test/FixIt/no-fixit.cpp +++ b/test/FixIt/no-fixit.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fdiagnostics-parseable-fixits -x c++ -std=c++11 %s 2>&1 | FileCheck %s +// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits -x c++ -std=c++11 %s 2>&1 | FileCheck %s // test that the diagnostics produced by this code do not include fixit hints diff --git a/test/FixIt/selector-fixit.m b/test/FixIt/selector-fixit.m new file mode 100644 index 0000000..e9d2f19 --- /dev/null +++ b/test/FixIt/selector-fixit.m @@ -0,0 +1,41 @@ +// RUN: cp %s %t +// RUN: %clang_cc1 -x objective-c -Wundeclared-selector -fixit %t +// RUN: %clang_cc1 -x objective-c -Wundeclared-selector -Werror %t +// rdar://14039037 + +@interface NSObject @end + +@interface LogoutController : NSObject +- (void)close; +- (void)closed; +- (void) open : (id) file_id; +@end + +@implementation LogoutController + +- (void)close { } +- (void)closed { } + +- (SEL)Meth +{ + return @selector(cloze); +} +- (void) open : (id) file_id {} + +- (SEL)Meth1 +{ + return @selector(ope:); +} + +@end + +// rdar://7853549 +@interface rdar7853549 : NSObject +- (int) bounds; +@end + +@implementation rdar7853549 +- (int) bounds { return 0; } +- (void)PrivateMeth { int bounds = [self bonds]; } +- (void)OtherPrivateMeth : (id) p { int bounds = [p bonds]; } +@end diff --git a/test/FixIt/typo-crash.cpp b/test/FixIt/typo-crash.cpp index c154e3b..4ea63c5 100644 --- a/test/FixIt/typo-crash.cpp +++ b/test/FixIt/typo-crash.cpp @@ -19,11 +19,12 @@ namespace PR12297 { namespace B { typedef short T; - T global(); // expected-note {{'A::B::global' declared here}} + T global(); // expected-note {{'::PR12297::global' declared here}} } } using namespace A::B; - T A::global(); // expected-error {{out-of-line definition of 'global' does not match any declaration in namespace 'PR12297::A'; did you mean 'A::B::global'?}} + // FIXME: Adding '::PR12297::' is not needed as removing 'A::' is sufficient + T A::global(); // expected-error {{out-of-line declaration of 'global' does not match any declaration in namespace 'PR12297::A'; did you mean '::PR12297::global'?}} } diff --git a/test/FixIt/typo-location-bugs.cpp b/test/FixIt/typo-location-bugs.cpp new file mode 100644 index 0000000..9c34a91 --- /dev/null +++ b/test/FixIt/typo-location-bugs.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: cp %s %t +// RUN: not %clang_cc1 -fsyntax-only -fixit -x c++ %t +// RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x c++ %t + +namespace dcl_fct_default_p10 { +struct A { + virtual void f(int a = 7); // expected-note{{'A::f' declared here}} +}; + +struct B : public A { + void f(int a); +}; + +void m() { + B* pb = new B; + A* pa = pb; + pa->f(); // OK, calls pa->B::f(7) + pb->f(); // expected-error{{too few arguments to function call, expected 1, have 0; did you mean 'A::f'?}} +} +} diff --git a/test/FixIt/typo-using.cpp b/test/FixIt/typo-using.cpp new file mode 100644 index 0000000..e676b10 --- /dev/null +++ b/test/FixIt/typo-using.cpp @@ -0,0 +1,56 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: cp %s %t +// RUN: not %clang_cc1 -fsyntax-only -fixit -x c++ %t +// RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x c++ %t +// RUN: grep using_suggestion_tyname_ty_dropped_specifier %t + +// These tests have been separated from typo.cpp to keep the maximum typo +// correction counter from ticking over; this causes spurious failures. + +namespace using_suggestion_ty { +namespace N { class AAA {}; } // expected-note {{'AAA' declared here}} +using N::AAB; // expected-error {{no member named 'AAB' in namespace 'using_suggestion_ty::N'; did you mean 'AAA'?}} +} + +namespace using_suggestion_tyname_ty { +namespace N { class AAA {}; } // expected-note {{'AAA' declared here}} +using typename N::AAB; // expected-error {{no member named 'AAB' in namespace 'using_suggestion_tyname_ty::N'; did you mean 'AAA'?}} +} + +namespace using_suggestion_val { +namespace N { void FFF() {} } // expected-note {{'FFF' declared here}} +using N::FFG; // expected-error {{no member named 'FFG' in namespace 'using_suggestion_val::N'; did you mean 'FFF'?}} +} + +namespace using_suggestion_ty_dropped_specifier { +class ABC {}; // expected-note {{'::using_suggestion_ty_dropped_specifier::ABC' declared here}} +namespace N { } +using N::ABC; // expected-error {{no member named 'ABC' in namespace 'using_suggestion_ty_dropped_specifier::N'; did you mean '::using_suggestion_ty_dropped_specifier::ABC'?}} +} + +namespace using_suggestion_tyname_ty_dropped_specifier { +class BCD {}; // expected-note {{'::using_suggestion_tyname_ty_dropped_specifier::BCD' declared here}} +namespace N { } +using typename N::BCD; // expected-error {{no member named 'BCD' in namespace 'using_suggestion_tyname_ty_dropped_specifier::N'; did you mean '::using_suggestion_tyname_ty_dropped_specifier::BCD'?}} +} + +namespace using_suggestion_val_dropped_specifier { +void EFG() {} // expected-note {{'::using_suggestion_val_dropped_specifier::EFG' declared here}} +namespace N { } +using N::EFG; // expected-error {{no member named 'EFG' in namespace 'using_suggestion_val_dropped_specifier::N'; did you mean '::using_suggestion_val_dropped_specifier::EFG'?}} +} + +namespace using_suggestion_member_ty { +class CCC { public: typedef int AAA; }; // expected-note {{'AAA' declared here}} +class DDD : public CCC { public: using CCC::AAB; }; // expected-error {{no member named 'AAB' in 'using_suggestion_member_ty::CCC'; did you mean 'AAA'?}} +} + +namespace using_suggestion_member_val { +class CCC { public: void AAA() { } }; // expected-note {{'AAA' declared here}} +class DDD : public CCC { public: using CCC::AAB; }; // expected-error {{no member named 'AAB' in 'using_suggestion_member_val::CCC'; did you mean 'AAA'?}} +} + +namespace using_suggestion_member_tyname_ty { +class CCC { public: typedef int AAA; }; // expected-note {{'AAA' declared here}} +class DDD : public CCC { public: using typename CCC::AAB; }; // expected-error {{no member named 'AAB' in 'using_suggestion_member_tyname_ty::CCC'; did you mean 'AAA'?}} +} diff --git a/test/FixIt/typo.c b/test/FixIt/typo.c index 8e380c9..4f4c67b 100644 --- a/test/FixIt/typo.c +++ b/test/FixIt/typo.c @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s +// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s // RUN: cp %s %t // RUN: not %clang_cc1 -fsyntax-only -fixit -x c %t // RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x c %t diff --git a/test/FixIt/typo.cpp b/test/FixIt/typo.cpp index b3568a5..2a74399 100644 --- a/test/FixIt/typo.cpp +++ b/test/FixIt/typo.cpp @@ -5,8 +5,7 @@ // RUN: grep test_string %t namespace std { - template<typename T> class basic_string { // expected-note 2{{'basic_string' declared here}} \ - // expected-note {{'otherstd::basic_string' declared here}} + template<typename T> class basic_string { // expected-note 3{{'basic_string' declared here}} public: int find(const char *substr); // expected-note{{'find' declared here}} static const int npos = -1; // expected-note{{'npos' declared here}} @@ -84,8 +83,12 @@ namespace nonstd { yarn str4; // expected-error{{unknown type name 'yarn'; did you mean 'nonstd::yarn'?}} wibble::yarn str5; // expected-error{{no type named 'yarn' in namespace 'otherstd'; did you mean 'nonstd::yarn'?}} +namespace another { + template<typename T> class wide_string {}; // expected-note {{'another::wide_string' declared here}} +} int poit() { - nonstd::basic_string<char> str; // expected-error{{no template named 'basic_string' in namespace 'nonstd'; did you mean 'otherstd::basic_string'?}} + nonstd::basic_string<char> str; // expected-error{{no template named 'basic_string' in namespace 'nonstd'; did you mean simply 'basic_string'?}} + nonstd::wide_string<char> str2; // expected-error{{no template named 'wide_string' in namespace 'nonstd'; did you mean 'another::wide_string'?}} return wibble::narf; // expected-error{{no member named 'narf' in namespace 'otherstd'; did you mean 'nonstd::narf'?}} } @@ -124,3 +127,11 @@ void func2() { // to replace base::i with derived::i as we would for other qualified name misspellings. // d.base::i = 3; } + +class A { + void bar(int); +}; +void bar(int, int); // expected-note{{'::bar' declared here}} +void A::bar(int x) { + bar(x, 5); // expected-error{{too many arguments to function call, expected 1, have 2; did you mean '::bar'?}} +} |