diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-01-18 16:23:48 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-01-18 16:23:48 +0000 |
commit | 06d4ba388873e6d1cfa9cd715a8935ecc8cd2097 (patch) | |
tree | 3eb853da77d46cc77c4b017525a422f9ddb1385b /test/FixIt | |
parent | 30d791273d07fac9c0c1641a0731191bca6e8606 (diff) |
Notes
Diffstat (limited to 'test/FixIt')
-rw-r--r-- | test/FixIt/fixit-class-method-messaging.m | 30 | ||||
-rw-r--r-- | test/FixIt/fixit-cxx1y-compat.cpp | 2 | ||||
-rw-r--r-- | test/FixIt/fixit-errors.c | 10 | ||||
-rw-r--r-- | test/FixIt/fixit-unrecoverable.cpp | 4 | ||||
-rw-r--r-- | test/FixIt/fixit.cpp | 49 | ||||
-rw-r--r-- | test/FixIt/multiarg-selector-fixit.m | 15 | ||||
-rw-r--r-- | test/FixIt/property-access-fixit.m | 31 |
7 files changed, 135 insertions, 6 deletions
diff --git a/test/FixIt/fixit-class-method-messaging.m b/test/FixIt/fixit-class-method-messaging.m new file mode 100644 index 000000000000..e2592d0c87f8 --- /dev/null +++ b/test/FixIt/fixit-class-method-messaging.m @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s +// rdar://16263395 + +@interface NSObject @end + +@interface I : NSObject // expected-note 3 {{receiver is instance of class declared here}} ++ (id) ClassMeth; +- (I*) MethInstPI; +@end + +I* pi; + +I* foobar(); + +@implementation I +- (id) PrivInstMeth { + [ foobar() ClassMeth]; // expected-warning {{instance method '-ClassMeth' not found (return type defaults to 'id')}} \ + // expected-note {{receiver expression is here}} +// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:5-[[@LINE-2]]:13}:"I + [[self MethInstPI] ClassMeth]; // expected-warning {{instance method '-ClassMeth' not found (return type defaults to 'id')}} \ + // expected-note {{receiver expression is here}} +// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:4-[[@LINE-2]]:21}:"I + return [pi ClassMeth]; // expected-warning {{instance method '-ClassMeth' not found (return type defaults to 'id')}} \ + // expected-note {{receiver expression is here}} +// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:11-[[@LINE-2]]:13}:"I +} ++ (id) ClassMeth { return 0; } +- (I*) MethInstPI { return 0; } +@end diff --git a/test/FixIt/fixit-cxx1y-compat.cpp b/test/FixIt/fixit-cxx1y-compat.cpp index 9fd5ff26e558..819e3984c352 100644 --- a/test/FixIt/fixit-cxx1y-compat.cpp +++ b/test/FixIt/fixit-cxx1y-compat.cpp @@ -7,6 +7,6 @@ // This is a test of the code modification hints for C++1y-compatibility problems. struct S { - constexpr int &f(); // expected-warning {{'constexpr' non-static member function will not be implicitly 'const' in C++1y; add 'const' to avoid a change in behavior}} + constexpr int &f(); // expected-warning {{'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior}} int &f(); }; diff --git a/test/FixIt/fixit-errors.c b/test/FixIt/fixit-errors.c index c425fc8a2d95..d727adb6fdfb 100644 --- a/test/FixIt/fixit-errors.c +++ b/test/FixIt/fixit-errors.c @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s // RUN: cp %s %t // RUN: not %clang_cc1 -pedantic -fixit -x c %t -// RUN: %clang_cc1 -pedantic -Werror -x c %t +// RUN: %clang_cc1 -pedantic -Werror -Wno-invalid-noreturn -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 @@ -21,3 +21,11 @@ struct Point *get_origin(); void test_point() { (void)get_origin->x; // expected-error {{base of member reference is a function; perhaps you meant to call it with no arguments?}} } + +void noreturn_1() _Noreturn; // expected-error {{must precede function declarator}} +void noreturn_1() { + return; // expected-warning {{should not return}} +} +void noreturn_2() _Noreturn { // expected-error {{must precede function declarator}} + return; // expected-warning {{should not return}} +} diff --git a/test/FixIt/fixit-unrecoverable.cpp b/test/FixIt/fixit-unrecoverable.cpp index 1e1f1b8db210..f555792ed39b 100644 --- a/test/FixIt/fixit-unrecoverable.cpp +++ b/test/FixIt/fixit-unrecoverable.cpp @@ -6,7 +6,5 @@ // 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'?}} \ - // expected-error{{for function-style cast or type construction}} + return static_cst<float>(y); // expected-error{{use of undeclared identifier 'static_cst'; did you mean 'static_cast'?}} } - diff --git a/test/FixIt/fixit.cpp b/test/FixIt/fixit.cpp index f26493856560..585c216f90de 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: not %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++ -std=c++11 %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 @@ -308,6 +308,13 @@ namespace dtor_fixit { ~bar() { } // expected-error {{expected the class name after '~' to name a destructor}} // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:6-[[@LINE-1]]:9}:"foo" }; + + class bar { + ~bar(); + }; + ~bar::bar() {} // expected-error {{'~' in destructor name should be after nested name specifier}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:4}:"" + // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:9-[[@LINE-2]]:9}:"~" } namespace PR5066 { @@ -340,3 +347,43 @@ namespace PR15045 { return c->a; // expected-error {{member reference type 'PR15045::Cl0' is not a pointer; maybe you meant to use '.'?}} } } + +namespace curly_after_base_clause { +struct A { void f(); }; +struct B : A // expected-error{{expected '{' after base class list}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:13}:" {" + int i; +}; +struct C : A // expected-error{{expected '{' after base class list}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:13}:" {" + using A::f; +}; +struct D : A // expected-error{{expected '{' after base class list}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:13}:" {" + protected: +}; +struct E : A // expected-error{{expected '{' after base class list}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:13}:" {" + template<typename T> struct inner { }; +}; +struct F : A // expected-error{{expected '{' after base class list}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:13}:" {" + F() { } +}; +#if __cplusplus >= 201103L +struct G : A // expected-error{{expected '{' after base class list}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:13}:" {" + constexpr G(int) { } +}; +struct H : A // expected-error{{expected '{' after base class list}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:13}:" {" + static_assert(true, ""); +}; +#endif +} + +struct conversion_operator { + conversion_operator::* const operator int(); // expected-error {{put the complete type after 'operator'}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:32}:"" + // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:44-[[@LINE-2]]:44}:" conversion_operator::* const" +}; diff --git a/test/FixIt/multiarg-selector-fixit.m b/test/FixIt/multiarg-selector-fixit.m new file mode 100644 index 000000000000..d60d31282ce7 --- /dev/null +++ b/test/FixIt/multiarg-selector-fixit.m @@ -0,0 +1,15 @@ +// RUN: cp %s %t +// RUN: %clang_cc1 -x objective-c -fixit %t +// RUN: diff %t %s +// rdar://15756038 + +#define nil (void *)0 + +@interface NSObject +- (void)testDataSource:(id)object withMultipleArguments:(id)arguments; +@end + +int main() { + id obj; + [obj TestDataSource:nil withMultipleArguments:nil]; +} diff --git a/test/FixIt/property-access-fixit.m b/test/FixIt/property-access-fixit.m new file mode 100644 index 000000000000..8623d29b9629 --- /dev/null +++ b/test/FixIt/property-access-fixit.m @@ -0,0 +1,31 @@ +// RUN: cp %s %t +// RUN: %clang_cc1 -x objective-c -fixit %t +// RUN: %clang_cc1 -x objective-c -Werror %t +//rdar://17911746 + +@class BridgeFormatter; + +@interface NSObject ++ (id)new; +@end + +@interface X : NSObject +@property int x; +@property int Y; +@property(assign, readwrite, getter=formatter, setter=setFormatter:) BridgeFormatter* cppFormatter; +@end + +@implementation X +- (void) endit +{ + self.formatter = 0; +} +@end + +int main() +{ + X *obj = [X new]; + obj.X = 3; + obj.y = 4; + return obj.x + obj.Y; +} |