summaryrefslogtreecommitdiff
path: root/clang/test/FixIt
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/FixIt')
-rw-r--r--clang/test/FixIt/atomic-property.m29
-rw-r--r--clang/test/FixIt/auto-fixit.m11
-rw-r--r--clang/test/FixIt/dereference-addressof.c22
-rw-r--r--clang/test/FixIt/fixit-c90.c17
-rw-r--r--clang/test/FixIt/fixit-cxx0x.cpp110
-rw-r--r--clang/test/FixIt/fixit-cxx11-compat.cpp11
-rw-r--r--clang/test/FixIt/fixit-errors-1.c16
-rw-r--r--clang/test/FixIt/fixit-errors.c23
-rw-r--r--clang/test/FixIt/fixit-function-call.cpp118
-rw-r--r--clang/test/FixIt/fixit-missing-method-return-type.m24
-rw-r--r--clang/test/FixIt/fixit-objc-message.m38
-rw-r--r--clang/test/FixIt/fixit-objc.m69
-rw-r--r--clang/test/FixIt/fixit-pmem.cpp26
-rw-r--r--clang/test/FixIt/fixit-recompile.c6
-rw-r--r--clang/test/FixIt/fixit-recursive-block.c12
-rw-r--r--clang/test/FixIt/fixit-static-object-decl.m29
-rw-r--r--clang/test/FixIt/fixit-suffix.c5
-rw-r--r--clang/test/FixIt/fixit-unrecoverable.c8
-rw-r--r--clang/test/FixIt/fixit-unrecoverable.cpp12
-rw-r--r--clang/test/FixIt/fixit-vexing-parse-cxx0x.cpp21
-rw-r--r--clang/test/FixIt/fixit-vexing-parse.cpp89
-rw-r--r--clang/test/FixIt/fixit.c102
-rw-r--r--clang/test/FixIt/fixit.cpp206
-rw-r--r--clang/test/FixIt/no-fixit.cpp7
-rw-r--r--clang/test/FixIt/no-macro-fixit.c16
-rw-r--r--clang/test/FixIt/no-typo.c6
-rw-r--r--clang/test/FixIt/objc-literals.m44
-rw-r--r--clang/test/FixIt/typo-crash.cpp29
-rw-r--r--clang/test/FixIt/typo-crash.m6
-rw-r--r--clang/test/FixIt/typo.c37
-rw-r--r--clang/test/FixIt/typo.cpp88
-rw-r--r--clang/test/FixIt/typo.m167
32 files changed, 1404 insertions, 0 deletions
diff --git a/clang/test/FixIt/atomic-property.m b/clang/test/FixIt/atomic-property.m
new file mode 100644
index 0000000..9ede7f1
--- /dev/null
+++ b/clang/test/FixIt/atomic-property.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fdiagnostics-parseable-fixits -x objective-c -fobjc-arc %s 2>&1 | FileCheck %s
+
+@interface I
+@property id prop;
+@property (atomic) id atomic_prop;
+- (id) prop;
+- (id) atomic_prop;
+
+@property ( ) id prop1;
+
+@property (copy, atomic, readwrite) id atomic_prop1;
+
+@property (copy, readwrite) id prop2;
+@end
+
+@implementation I
+@synthesize prop, prop1, prop2;
+@synthesize atomic_prop, atomic_prop1;
+- (id) prop { return 0; }
+- (id) prop1 { return 0; }
+- (id) prop2 { return 0; }
+- (id) atomic_prop { return 0; }
+- (id) atomic_prop1 { return 0; }
+@end
+
+// CHECK: {4:1-4:10}:"@property (nonatomic) "
+// CHECK: {9:1-9:12}:"@property (nonatomic"
+// CHECK: {13:1-13:12}:"@property (nonatomic, "
+
diff --git a/clang/test/FixIt/auto-fixit.m b/clang/test/FixIt/auto-fixit.m
new file mode 100644
index 0000000..d09f04c
--- /dev/null
+++ b/clang/test/FixIt/auto-fixit.m
@@ -0,0 +1,11 @@
+/* RUN: cp %s %t
+ RUN: %clang_cc1 -x objective-c -fixit %t
+ RUN: %clang_cc1 -x objective-c -Werror %t
+ */
+
+// rdar://9036633
+
+int main() {
+ auto int i = 0;
+ return i;
+}
diff --git a/clang/test/FixIt/dereference-addressof.c b/clang/test/FixIt/dereference-addressof.c
new file mode 100644
index 0000000..950fadc
--- /dev/null
+++ b/clang/test/FixIt/dereference-addressof.c
@@ -0,0 +1,22 @@
+// 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 -x c %t
+
+void ip(int *aPtr) {} // expected-note{{passing argument to parameter 'aPtr' here}}
+void i(int a) {} // expected-note{{passing argument to parameter 'a' here}}
+void ii(int a) {} // expected-note{{passing argument to parameter 'a' here}}
+void fp(float *aPtr) {} // expected-note{{passing argument to parameter 'aPtr' here}}
+void f(float a) {} // expected-note{{passing argument to parameter 'a' here}}
+
+void f2(int *aPtr, int a, float *bPtr, char c) {
+ float fl = 0;
+ ip(a); // expected-warning{{incompatible integer to pointer conversion passing 'int' to parameter of type 'int *'; take the address with &}}
+ i(aPtr); // expected-warning{{incompatible pointer to integer conversion passing 'int *' to parameter of type 'int'; dereference with *}}
+ ii(&a); // expected-warning{{incompatible pointer to integer conversion passing 'int *' to parameter of type 'int'; remove &}}
+ fp(*bPtr); // expected-error{{passing 'float' to parameter of incompatible type 'float *'; remove *}}
+ f(bPtr); // expected-error{{passing 'float *' to parameter of incompatible type 'float'; dereference with *}}
+ a = aPtr; // expected-warning{{incompatible pointer to integer conversion assigning to 'int' from 'int *'; dereference with *}}
+ fl = bPtr + a; // expected-error{{assigning to 'float' from incompatible type 'float *'; dereference with *}}
+ bPtr = bPtr[a]; // expected-error{{assigning to 'float *' from incompatible type 'float'; take the address with &}}
+}
diff --git a/clang/test/FixIt/fixit-c90.c b/clang/test/FixIt/fixit-c90.c
new file mode 100644
index 0000000..0bc1fad
--- /dev/null
+++ b/clang/test/FixIt/fixit-c90.c
@@ -0,0 +1,17 @@
+/* RUN: cp %s %t
+ RUN: %clang_cc1 -std=c90 -pedantic -fixit %t
+ RUN: %clang_cc1 -pedantic -x c -std=c90 -Werror %t
+ */
+/* XPASS: *
+ This test passes because clang merely warns for this syntax error even with
+ -pedantic -Werror -std=c90.
+ */
+
+/* This is a test of the various code modification hints that are
+ provided as part of warning or extension diagnostics. All of the
+ warnings will be fixed by -fixit, and the resulting file should
+ compile cleanly with -Werror -pedantic. */
+
+enum e0 {
+ e1,
+};
diff --git a/clang/test/FixIt/fixit-cxx0x.cpp b/clang/test/FixIt/fixit-cxx0x.cpp
new file mode 100644
index 0000000..b6cc2c0
--- /dev/null
+++ b/clang/test/FixIt/fixit-cxx0x.cpp
@@ -0,0 +1,110 @@
+// RUN: %clang_cc1 -verify -std=c++11 %s
+// 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
+
+/* This is a test of the various code modification hints that only
+ apply in C++0x. */
+struct A {
+ explicit operator int(); // expected-note{{conversion to integral type}}
+};
+
+void x() {
+ switch(A()) { // expected-error{{explicit conversion to}}
+ }
+}
+
+using ::T = void; // expected-error {{name defined in alias declaration must be an identifier}}
+using typename U = void; // expected-error {{name defined in alias declaration must be an identifier}}
+using typename ::V = void; // expected-error {{name defined in alias declaration must be an identifier}}
+
+namespace SemiCommaTypo {
+ int m {},
+ n [[]], // expected-error {{expected ';' at end of declaration}}
+ int o;
+
+ struct Base {
+ virtual void f2(), f3();
+ };
+ struct MemberDeclarator : Base {
+ int k : 4,
+ //[[]] : 1, FIXME: test this once we support attributes here
+ : 9, // expected-error {{expected ';' at end of declaration}}
+ char c, // expected-error {{expected ';' at end of declaration}}
+ typedef void F(), // expected-error {{expected ';' at end of declaration}}
+ F f1,
+ f2 final,
+ f3 override, // expected-error {{expected ';' at end of declaration}}
+ };
+}
+
+namespace ScopedEnum {
+ enum class E { a };
+
+ enum class E b = E::a; // expected-error {{must use 'enum' not 'enum class'}}
+ struct S {
+ friend enum class E; // expected-error {{must use 'enum' not 'enum class'}}
+ };
+}
+
+struct S2 {
+ void f(int i);
+ void g(int i);
+};
+
+void S2::f(int i) {
+ (void)[&, &i, &i]{}; // expected-error 2{{'&' cannot precede a capture when the capture default is '&'}}
+ (void)[=, this]{ this->g(5); }; // expected-error{{'this' cannot be explicitly captured}}
+ (void)[i, i]{ }; // expected-error{{'i' can appear only once in a capture list}}
+ (void)[&, i, i]{ }; // expected-error{{'i' can appear only once in a capture list}}
+ (void)[] mutable { }; // expected-error{{lambda requires '()' before 'mutable'}}
+ (void)[] -> int { }; // expected-error{{lambda requires '()' before return type}}
+}
+
+#define bar "bar"
+const char *p = "foo"bar; // expected-error {{requires a space between}}
+#define ord - '0'
+int k = '4'ord; // expected-error {{requires a space between}}
+
+void operator""_x(char); // expected-error {{requires a space}}
+void operator"x" _y(char); // expected-error {{must be '""'}}
+void operator L"" _z(char); // expected-error {{encoding prefix}}
+void operator "x" "y" U"z" ""_whoops "z" "y"(char); // expected-error {{must be '""'}}
+
+void f() {
+ 'a'_x;
+ 'b'_y;
+ 'c'_z;
+ 'd'_whoops;
+}
+
+template<typename ...Ts> struct MisplacedEllipsis {
+ int a(Ts ...(x)); // expected-error {{'...' must immediately precede declared identifier}}
+ int b(Ts ...&x); // expected-error {{'...' must immediately precede declared identifier}}
+ int c(Ts ...&); // expected-error {{'...' must be innermost component of anonymous pack declaration}}
+ int d(Ts ...(...&...)); // expected-error 2{{'...' must be innermost component of anonymous pack declaration}}
+ int e(Ts ...*[]); // expected-error {{'...' must be innermost component of anonymous pack declaration}}
+ int f(Ts ...(...*)()); // expected-error 2{{'...' must be innermost component of anonymous pack declaration}}
+ int g(Ts ...()); // ok
+};
+namespace TestMisplacedEllipsisRecovery {
+ MisplacedEllipsis<int, char> me;
+ int i; char k;
+ int *ip; char *kp;
+ int ifn(); char kfn();
+ int a = me.a(i, k);
+ int b = me.b(i, k);
+ int c = me.c(i, k);
+ int d = me.d(i, k);
+ int e = me.e(&ip, &kp);
+ int f = me.f(ifn, kfn);
+ int g = me.g(ifn, kfn);
+}
+
+template<template<typename> ...Foo, // expected-error {{template template parameter requires 'class' after the parameter list}}
+ template<template<template<typename>>>> // expected-error 3 {{template template parameter requires 'class' after the parameter list}}
+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 *'}}
+
diff --git a/clang/test/FixIt/fixit-cxx11-compat.cpp b/clang/test/FixIt/fixit-cxx11-compat.cpp
new file mode 100644
index 0000000..39ae439
--- /dev/null
+++ b/clang/test/FixIt/fixit-cxx11-compat.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -Wc++11-compat -verify -std=c++98 %s
+// RUN: cp %s %t
+// RUN: not %clang_cc1 -Wc++11-compat -Werror -x c++ -std=c++98 -fixit %t
+// RUN: %clang_cc1 -Wall -pedantic-errors -Wc++11-compat -Werror -x c++ -std=c++98 %t
+
+// This is a test of the code modification hints for C++11-compatibility problems.
+
+#define bar "bar"
+const char *p = "foo"bar; // expected-warning {{will be treated as a reserved user-defined literal suffix}}
+#define _bar "_bar"
+const char *q = "foo"_bar; // expected-warning {{will be treated as a user-defined literal suffix}}
diff --git a/clang/test/FixIt/fixit-errors-1.c b/clang/test/FixIt/fixit-errors-1.c
new file mode 100644
index 0000000..96f27eb
--- /dev/null
+++ b/clang/test/FixIt/fixit-errors-1.c
@@ -0,0 +1,16 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -pedantic -fixit %t
+// RUN: echo %clang_cc1 -pedantic -Werror -x c %t
+/* XPASS: * */
+
+/* This is a test of the various code modification hints that are
+ provided as part of warning or extension diagnostics. All of the
+ warnings will be fixed by -fixit, and the resulting file should
+ compile cleanly with -Werror -pedantic. */
+
+// FIXME: If you put a space at the end of the line, it doesn't work yet!
+char *s = "hi\
+there";
+
+// The following line isn't terminated, don't fix it.
+int i; // expected-error{{no newline at end of file}}
diff --git a/clang/test/FixIt/fixit-errors.c b/clang/test/FixIt/fixit-errors.c
new file mode 100644
index 0000000..356e862
--- /dev/null
+++ b/clang/test/FixIt/fixit-errors.c
@@ -0,0 +1,23 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -pedantic -verify -fixit -x c %t
+// RUN: %clang_cc1 -pedantic -Werror -x c %t
+// XFAIL: *
+
+/* This is a test of the various code modification hints that are
+ provided as part of warning or extension diagnostics. All of the
+ warnings will be fixed by -fixit, and the resulting file should
+ compile cleanly with -Werror -pedantic. */
+
+struct s; // expected-note{{previous use is here}}
+
+union s *s1; // expected-error{{use of 's' with tag type that does not match previous declaration}}
+
+struct Point {
+ float x, y, z;
+};
+
+struct Point *get_origin();
+
+void test_point() {
+ (void)get_origin->x;
+}
diff --git a/clang/test/FixIt/fixit-function-call.cpp b/clang/test/FixIt/fixit-function-call.cpp
new file mode 100644
index 0000000..273e4a4
--- /dev/null
+++ b/clang/test/FixIt/fixit-function-call.cpp
@@ -0,0 +1,118 @@
+// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits -x c++ %s 2> %t
+// RUN: FileCheck %s < %t
+// PR5941
+// END.
+
+/* Test fixits for * and & mismatch in function arguments.
+ * Since fixits are on the notes, they cannot be applied automatically. */
+
+typedef int intTy;
+typedef int intTy2;
+
+void f0(int *a);
+void f1(double *a);
+void f1(intTy &a);
+
+void f2(intTy2 *a) {
+// CHECK: error: no matching function for call to 'f1
+// CHECK: dereference the argument with *
+// CHECK: void f1(intTy &a);
+// CHECK: fix-it{{.*}}*(
+// CHECK-NEXT: fix-it{{.*}})
+// CHECK: void f1(double *a);
+ f1(a + 1);
+
+// This call cannot be fixed since without resulting in null pointer dereference.
+// CHECK: error: no matching function for call to 'f1
+// CHECK-NOT: dereference the argument with *
+// CHECK-NOT: fix-it
+ f1((int *)0);
+}
+
+void f3(int &a) {
+// CHECK: error: no matching function for call to 'f0
+// CHECK: fix-it{{.*}}&
+ f0(a);
+}
+
+
+void m(int *a, const int *b); // match 2
+void m(double *a, int *b); // no match
+void m(int *a, double *b); // no match
+void m(intTy &a, int *b); // match 1
+
+void mcaller(intTy2 a, int b) {
+// CHECK: error: no matching function for call to 'm
+// CHECK: take the address of the argument with &
+// CHECK: fix-it{{.*}}&
+// CHECK: take the address of the argument with &
+// CHECK: fix-it{{.*}}&
+// CHECK: fix-it{{.*}}&
+ m(a, b);
+
+// This call cannot be fixed because (a + 1) is not an l-value.
+// CHECK: error: no matching function for call to 'm
+// CHECK-NOT: fix-it
+ m(a + 1, b);
+}
+
+// Test derived to base conversions.
+struct A {
+ int xx;
+};
+
+struct B : public A {
+ double y;
+};
+
+class C : A {};
+
+bool br(A &a);
+bool bp(A *a);
+bool dv(B b);
+
+void u(int x);
+void u(const C *x);
+void u(double x);
+
+void dbcaller(A *ptra, B *ptrb, C &c, B &refb) {
+ B b;
+
+// CHECK: error: no matching function for call to 'br
+// CHECK: fix-it{{.*}}*
+ br(ptrb); // good
+
+// CHECK: error: no matching function for call to 'bp
+// CHECK: fix-it{{.*}}&
+ bp(b); // good
+
+// CHECK: error: no matching function for call to 'dv
+// CHECK-NOT: fix-it
+ dv(ptra); // bad: base to derived
+
+// CHECK: error: no matching function for call to 'dv
+// CHECK: remove &
+ dv(&b);
+
+// CHECK: error: no matching function for call to 'bp
+// CHECK: remove *
+ bp(*ptra);
+
+// CHECK: error: no viable overloaded '='
+// CHECK: remove &
+ b = &refb;
+
+// TODO: Test that we do not provide a fixit when inheritance is private.
+// CHECK: error: no matching function for call to 'bp
+// There should not be a fixit here:
+// CHECK: fix-it
+ bp(c);
+
+// CHECK: no matching function for call to 'u'
+// CHECK: candidate function not viable: no known conversion from 'C' to 'const C *' for 1st argument; take the address of the argument with &
+// CHECK: candidate function not viable
+// CHECK: candidate function not viable
+ u(c);
+}
+
+// CHECK: errors generated
diff --git a/clang/test/FixIt/fixit-missing-method-return-type.m b/clang/test/FixIt/fixit-missing-method-return-type.m
new file mode 100644
index 0000000..769fbe8
--- /dev/null
+++ b/clang/test/FixIt/fixit-missing-method-return-type.m
@@ -0,0 +1,24 @@
+// Objective-C recovery
+// RUN: cp %s %t
+// RUN: %clang_cc1 -Wmissing-method-return-type -fixit -x objective-c -Wno-objc-root-class %t
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Wmissing-method-return-type -Werror -x objective-c -Wno-objc-root-class %t
+
+// Objective-C++ recovery
+// RUN: cp %s %t
+// RUN: %clang_cc1 -Wmissing-method-return-type -fixit -x objective-c++ -Wno-objc-root-class %t
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Wmissing-method-return-type -Werror -x objective-c++ -Wno-objc-root-class %t
+// rdar://9615045
+
+@interface I
+- initWithFoo:(id)foo; // expected-warning {{method has no return type specified; defaults to 'id' [-Wmissing-method-return-type]}}
+- Meth;
+-Meth1;
+@end
+
+@implementation I
+- initWithFoo:(id)foo { return 0; } // expected-warning {{method has no return type specified; defaults to 'id' [-Wmissing-method-return-type]}}
+
+-Meth { return 0;}
+- Meth1 { return 0;}
+@end
+
diff --git a/clang/test/FixIt/fixit-objc-message.m b/clang/test/FixIt/fixit-objc-message.m
new file mode 100644
index 0000000..a3680e4
--- /dev/null
+++ b/clang/test/FixIt/fixit-objc-message.m
@@ -0,0 +1,38 @@
+// Objective-C recovery
+// RUN: cp %s %t
+// RUN: not %clang_cc1 -pedantic -Wall -fixit -x objective-c %t
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -x objective-c %t
+
+// Objective-C++ recovery
+// RUN: cp %s %t
+// RUN: not %clang_cc1 -pedantic -Wall -fixit -x objective-c++ %t
+// 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/clang/test/FixIt/fixit-objc.m b/clang/test/FixIt/fixit-objc.m
new file mode 100644
index 0000000..df591c7
--- /dev/null
+++ b/clang/test/FixIt/fixit-objc.m
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -pedantic -verify %s
+// RUN: cp %s %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
+ warnings will be fixed by -fixit, and the resulting file should
+ compile cleanly with -Werror -pedantic. */
+
+@protocol X;
+
+void foo() {
+ <X> *P; // expected-warning{{protocol qualifiers without 'id' is archaic}}
+}
+
+@class A;
+@class NSString;
+
+@interface Test
+- (void)test:(NSString *)string; // expected-note{{passing argument to parameter 'string' here}}
+
+@property (copy) NSString *property;
+@end
+
+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]'}}
+ 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 ';'}}
+}
+
+// rdar://7861841
+@interface Radar7861841 {
+@public
+ int x;
+}
+
+@property (assign) int y;
+@end
+
+int f0(Radar7861841 *a) { return a.x; } // expected-error {{property 'x' not found on object of type 'Radar7861841 *'; did you mean to access ivar 'x'}}
+
+int f1(Radar7861841 *a) { return a->y; } // expected-error {{property 'y' found on object of type 'Radar7861841 *'; did you mean to access it with the "." operator?}}
+
+
+#define nil ((void*)0)
+#define NULL ((void*)0)
+
+void sentinel(int x, ...) __attribute__((sentinel)); // expected-note{{function has been explicitly marked sentinel here}}
+
+@interface Sentinel
+- (void)sentinel:(int)x, ... __attribute__((sentinel)); // expected-note{{method has been explicitly marked sentinel here}}
+@end
+
+void sentinel_test(Sentinel *a) {
+ sentinel(1, 2, 3); // expected-warning{{missing sentinel in function call}}
+ [a sentinel:1, 2, 3]; // expected-warning{{missing sentinel in method dispatch}}
+}
diff --git a/clang/test/FixIt/fixit-pmem.cpp b/clang/test/FixIt/fixit-pmem.cpp
new file mode 100644
index 0000000..b69eadf
--- /dev/null
+++ b/clang/test/FixIt/fixit-pmem.cpp
@@ -0,0 +1,26 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -pedantic -fixit -x c++ %t
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x c++ %t
+// XFAIL: *
+
+/* This is a test of the various code modification hints that are
+ provided as part of warning or extension diagnostics. All of the
+ warnings will be fixed by -fixit, and the resulting file should
+ compile cleanly with -Werror -pedantic. */
+
+struct S {
+ int i;
+};
+
+int foo(int S::* ps, S s, S* p)
+{
+ p.*ps = 1;
+ return s->*ps;
+}
+
+void foo1(int (S::*ps)(), S s, S* p)
+{
+ (p.*ps)();
+ (s->*ps)();
+}
+
diff --git a/clang/test/FixIt/fixit-recompile.c b/clang/test/FixIt/fixit-recompile.c
new file mode 100644
index 0000000..a2e62fb
--- /dev/null
+++ b/clang/test/FixIt/fixit-recompile.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -Werror -pedantic %s -fixit-recompile -fixit-to-temporary -E -o - | FileCheck %s
+// RUN: not %clang_cc1 -Werror -pedantic %s -fixit-recompile -fixit-to-temporary -fix-only-warnings
+
+_Complex cd;
+
+// CHECK: _Complex double cd;
diff --git a/clang/test/FixIt/fixit-recursive-block.c b/clang/test/FixIt/fixit-recursive-block.c
new file mode 100644
index 0000000..b276b41
--- /dev/null
+++ b/clang/test/FixIt/fixit-recursive-block.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Wuninitialized -fblocks -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Wuninitialized -fblocks -verify %s
+
+// rdar://10817031
+
+int main() {
+ void (^arc_fail)() = ^() { // expected-warning {{block pointer variable 'arc_fail' is uninitialized when captured by block}} \
+ // expected-note {{maybe you meant to use __block 'arc_fail'}}
+ arc_fail(); // BOOM
+ };
+}
+// CHECK: {7:12-7:12}:"__block "
diff --git a/clang/test/FixIt/fixit-static-object-decl.m b/clang/test/FixIt/fixit-static-object-decl.m
new file mode 100644
index 0000000..e13900f
--- /dev/null
+++ b/clang/test/FixIt/fixit-static-object-decl.m
@@ -0,0 +1,29 @@
+// 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
+
+// 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
+// rdar://9603056
+
+@interface S @end
+
+@interface NSArray
+{
+@public
+ S iS;
+}
++ (id) arrayWithObjects;
+@end
+
+NSArray func() {
+ NSArray P;
+ return P;
+}
+
+int main() {
+ NSArray pluginNames = [NSArray arrayWithObjects];
+}
diff --git a/clang/test/FixIt/fixit-suffix.c b/clang/test/FixIt/fixit-suffix.c
new file mode 100644
index 0000000..a1a747a
--- /dev/null
+++ b/clang/test/FixIt/fixit-suffix.c
@@ -0,0 +1,5 @@
+// RUN: cp %s %t.extrasuffix
+// RUN: %clang_cc1 -fixit=fixed -x c %t.extrasuffix
+// RUN: %clang_cc1 -Werror -pedantic -x c %t.fixed.extrasuffix
+
+_Complex cd;
diff --git a/clang/test/FixIt/fixit-unrecoverable.c b/clang/test/FixIt/fixit-unrecoverable.c
new file mode 100644
index 0000000..fb6c4e2
--- /dev/null
+++ b/clang/test/FixIt/fixit-unrecoverable.c
@@ -0,0 +1,8 @@
+/* FIXME: This is a file containing various typos for which we can
+ suggest corrections but are unable to actually recover from
+ them. Ideally, we would eliminate all such cases and move these
+ tests elsewhere. */
+
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+unsinged x = 17; // expected-error{{unknown type name 'unsinged'; did you mean 'unsigned'?}}
diff --git a/clang/test/FixIt/fixit-unrecoverable.cpp b/clang/test/FixIt/fixit-unrecoverable.cpp
new file mode 100644
index 0000000..1e1f1b8
--- /dev/null
+++ b/clang/test/FixIt/fixit-unrecoverable.cpp
@@ -0,0 +1,12 @@
+/* FIXME: This is a file containing various typos for which we can
+ suggest corrections but are unable to actually recover from
+ them. Ideally, we would eliminate all such cases and move these
+ tests elsewhere. */
+
+// 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}}
+}
+
diff --git a/clang/test/FixIt/fixit-vexing-parse-cxx0x.cpp b/clang/test/FixIt/fixit-vexing-parse-cxx0x.cpp
new file mode 100644
index 0000000..a870794
--- /dev/null
+++ b/clang/test/FixIt/fixit-vexing-parse-cxx0x.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -verify -x c++ -std=c++11 %s
+// RUN: %clang_cc1 -fdiagnostics-parseable-fixits -x c++ -std=c++11 %s 2>&1 | FileCheck %s
+
+struct X {
+ int i;
+};
+
+void func() {
+ // CHECK: fix-it:"{{.*}}":{10:6-10:8}:"{}"
+ X x(); // expected-warning {{function declaration}} expected-note{{replace parentheses with an initializer}}
+
+ typedef int *Ptr;
+ // CHECK: fix-it:"{{.*}}":{14:8-14:10}:" = nullptr"
+ Ptr p(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ // CHECK: fix-it:"{{.*}}":{17:15-17:17}:" = u'\\0'"
+ char16_t u16(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ // CHECK: fix-it:"{{.*}}":{20:15-20:17}:" = U'\\0'"
+ char32_t u32(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+}
diff --git a/clang/test/FixIt/fixit-vexing-parse.cpp b/clang/test/FixIt/fixit-vexing-parse.cpp
new file mode 100644
index 0000000..8450590
--- /dev/null
+++ b/clang/test/FixIt/fixit-vexing-parse.cpp
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -verify -x c++ %s
+// RUN: %clang_cc1 -fdiagnostics-parseable-fixits -x c++ %s 2>&1 | FileCheck %s
+
+struct S {
+ int n;
+};
+
+struct T {
+ T();
+ int n;
+};
+
+struct U {
+ ~U();
+ int n;
+};
+
+struct V {
+ ~V();
+};
+
+struct W : V {
+};
+
+struct X : U {
+};
+
+int F1();
+S F2();
+
+namespace N {
+ void test() {
+ // CHECK: fix-it:"{{.*}}":{34:9-34: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}:" = {}"
+ 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}:""
+ 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}:" = {}"
+ U u(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ // CHECK: fix-it:"{{.*}}":{50:8-50:10}:""
+ V v(); // expected-warning {{function declaration}} expected-note {{remove parentheses}}
+
+ // CHECK: fix-it:"{{.*}}":{53:8-53:10}:""
+ W w(); // expected-warning {{function declaration}} expected-note {{remove parentheses}}
+
+ // TODO: Removing the parens here would not initialize U::n.
+ // Maybe suggest an " = X()" initializer for this case?
+ // Maybe suggest removing the parens anyway?
+ X x(); // expected-warning {{function declaration}}
+
+ // CHECK: fix-it:"{{.*}}":{61:11-61: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"
+ 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"
+ double d(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ typedef void *Ptr;
+
+ // CHECK: fix-it:"{{.*}}":{74:10-74: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"
+ Ptr p(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ // CHECK: fix-it:"{{.*}}":{81:11-81:13}:" = false"
+ bool b(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ // CHECK: fix-it:"{{.*}}":{84:11-84:13}:" = '\\0'"
+ char c(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ // CHECK: fix-it:"{{.*}}":{87:15-87:17}:" = L'\\0'"
+ wchar_t wc(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+ }
+}
diff --git a/clang/test/FixIt/fixit.c b/clang/test/FixIt/fixit.c
new file mode 100644
index 0000000..5e4947b
--- /dev/null
+++ b/clang/test/FixIt/fixit.c
@@ -0,0 +1,102 @@
+// RUN: %clang_cc1 -pedantic -Wunused-label -verify -x c %s
+// RUN: cp %s %t
+// RUN: not %clang_cc1 -pedantic -Wunused-label -fixit -x c %t
+// RUN: grep -v CHECK %t > %t2
+// RUN: %clang_cc1 -pedantic -Wunused-label -Werror -x c %t
+// RUN: FileCheck -input-file=%t2 %t
+
+/* This is a test of the various code modification hints that are
+ provided as part of warning or extension diagnostics. All of the
+ warnings will be fixed by -fixit, and the resulting file should
+ compile cleanly with -Werror -pedantic. */
+
+// FIXME: FIX-IT should add #include <string.h>?
+int strcmp(const char *s1, const char *s2);
+
+void f0(void) { }; // expected-warning {{';'}}
+
+struct s {
+ int x, y;; // expected-warning {{extra ';'}}
+};
+
+// CHECK: _Complex double cd;
+_Complex cd; // expected-warning {{assuming '_Complex double'}}
+
+// CHECK: struct s s0 = { .y = 5 };
+struct s s0 = { y: 5 }; // expected-warning {{GNU old-style}}
+
+// CHECK: int array0[5] = { [3] = 3 };
+int array0[5] = { [3] 3 }; // expected-warning {{GNU 'missing ='}}
+
+// CHECK: int x
+// CHECK: int y
+void f1(x, y) // expected-warning 2{{defaulting to type 'int'}}
+{
+}
+
+int i0 = { 17 };
+
+#define ONE 1
+#define TWO 2
+
+int test_cond(int y, int fooBar) { // expected-note {{here}}
+// CHECK: int x = y ? 1 : 4+fooBar;
+ int x = y ? 1 4+foobar; // expected-error {{expected ':'}} expected-error {{undeclared identifier}} expected-note {{to match}}
+// CHECK: x = y ? ONE : TWO;
+ x = y ? ONE TWO; // expected-error {{':'}} expected-note {{to match}}
+ return x;
+}
+
+// CHECK: const typedef int int_t;
+const typedef typedef int int_t; // expected-warning {{duplicate 'typedef'}}
+
+// <rdar://problem/7159693>
+enum Color {
+ Red // expected-error{{missing ',' between enumerators}}
+ Green = 17 // expected-error{{missing ',' between enumerators}}
+ Blue,
+};
+
+// rdar://9295072
+struct test_struct {
+ // CHECK: struct test_struct *struct_ptr;
+ test_struct *struct_ptr; // expected-error {{must use 'struct' tag to refer to type 'test_struct'}}
+};
+
+void removeUnusedLabels(char c) {
+ L0 /*removed comment*/: c++; // expected-warning {{unused label}}
+ removeUnusedLabels(c);
+ L1: // expected-warning {{unused label}}
+ c++;
+ /*preserved comment*/ L2 : c++; // expected-warning {{unused label}}
+ LL // expected-warning {{unused label}}
+ : c++;
+ c = c + 3; L4: return; // expected-warning {{unused label}}
+}
+
+int oopsAComma = 0, // expected-error {{';'}}
+void oopsMoreCommas() {
+ static int a[] = { 0, 1, 2 }, // expected-error {{';'}}
+ static int b[] = { 3, 4, 5 }, // expected-error {{';'}}
+ &a == &b ? oopsMoreCommas() : removeUnusedLabels(a[0]);
+}
+
+int noSemiAfterLabel(int n) {
+ switch (n) {
+ default:
+ return n % 4;
+ case 0:
+ case 1:
+ case 2:
+ // CHECK: /*FOO*/ case 3: ;
+ /*FOO*/ case 3: // expected-error {{expected statement}}
+ }
+ switch (n) {
+ case 1:
+ case 2:
+ return 0;
+ // CHECK: /*BAR*/ default: ;
+ /*BAR*/ default: // expected-error {{expected statement}}
+ }
+ return 1;
+}
diff --git a/clang/test/FixIt/fixit.cpp b/clang/test/FixIt/fixit.cpp
new file mode 100644
index 0000000..7d531a5
--- /dev/null
+++ b/clang/test/FixIt/fixit.cpp
@@ -0,0 +1,206 @@
+// RUN: %clang_cc1 -pedantic -Wall -Wno-comment -verify -fcxx-exceptions -x c++ %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
+
+/* This is a test of the various code modification hints that are
+ provided as part of warning or extension diagnostics. All of the
+ warnings will be fixed by -fixit, and the resulting file should
+ compile cleanly with -Werror -pedantic. */
+
+struct C1 {
+ virtual void f();
+ static void g();
+};
+struct C2 : virtual public virtual C1 { }; // expected-error{{duplicate}}
+
+virtual void C1::f() { } // expected-error{{'virtual' can only be specified inside the class definition}}
+
+static void C1::g() { } // expected-error{{'static' can only be specified inside the class definition}}
+
+template<int Value> struct CT { }; // expected-note{{previous use is here}}
+
+CT<10 >> 2> ct; // expected-warning{{require parentheses}}
+
+class C3 {
+public:
+ C3(C3, int i = 0); // expected-error{{copy constructor must pass its first argument by reference}}
+};
+
+struct CT<0> { }; // expected-error{{'template<>'}}
+
+template<> union CT<1> { }; // expected-error{{tag type}}
+
+// Access declarations
+class A {
+protected:
+ int foo();
+};
+
+class B : public A {
+ A::foo; // expected-warning{{access declarations are deprecated}}
+};
+
+void f() throw(); // expected-note{{previous}}
+void f(); // expected-warning{{missing exception specification}}
+
+namespace rdar7853795 {
+ struct A {
+ bool getNumComponents() const; // expected-note{{declared here}}
+ void dump() const {
+ getNumComponenets(); // expected-error{{use of undeclared identifier 'getNumComponenets'; did you mean 'getNumComponents'?}}
+ }
+ };
+}
+
+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(); // expected-warning {{extra qualification}}
+};
+
+namespace rdar8488464 {
+int x = 0;
+int x1 &= 0; // expected-error {{invalid '&=' at end of declaration; did you mean '='?}}
+int x2 *= 0; // expected-error {{invalid '*=' at end of declaration; did you mean '='?}}
+int x3 += 0; // expected-error {{invalid '+=' at end of declaration; did you mean '='?}}
+int x4 -= 0; // expected-error {{invalid '-=' at end of declaration; did you mean '='?}}
+int x5 != 0; // expected-error {{invalid '!=' at end of declaration; did you mean '='?}}
+int x6 /= 0; // expected-error {{invalid '/=' at end of declaration; did you mean '='?}}
+int x7 %= 0; // expected-error {{invalid '%=' at end of declaration; did you mean '='?}}
+int x8 <= 0; // expected-error {{invalid '<=' at end of declaration; did you mean '='?}}
+int x9 <<= 0; // expected-error {{invalid '<<=' at end of declaration; did you mean '='?}}
+int x10 >= 0; // expected-error {{invalid '>=' at end of declaration; did you mean '='?}}
+int x11 >>= 0; // expected-error {{invalid '>>=' at end of declaration; did you mean '='?}}
+int x12 ^= 0; // expected-error {{invalid '^=' at end of declaration; did you mean '='?}}
+int x13 |= 0; // expected-error {{invalid '|=' at end of declaration; did you mean '='?}}
+int x14 == 0; // expected-error {{invalid '==' at end of declaration; did you mean '='?}}
+
+void f() {
+ int x = 0;
+ (void)x;
+ int x1 &= 0; // expected-error {{invalid '&=' at end of declaration; did you mean '='?}}
+ (void)x1;
+ int x2 *= 0; // expected-error {{invalid '*=' at end of declaration; did you mean '='?}}
+ (void)x2;
+ int x3 += 0; // expected-error {{invalid '+=' at end of declaration; did you mean '='?}}
+ (void)x3;
+ int x4 -= 0; // expected-error {{invalid '-=' at end of declaration; did you mean '='?}}
+ (void)x4;
+ int x5 != 0; // expected-error {{invalid '!=' at end of declaration; did you mean '='?}}
+ (void)x5;
+ int x6 /= 0; // expected-error {{invalid '/=' at end of declaration; did you mean '='?}}
+ (void)x6;
+ int x7 %= 0; // expected-error {{invalid '%=' at end of declaration; did you mean '='?}}
+ (void)x7;
+ int x8 <= 0; // expected-error {{invalid '<=' at end of declaration; did you mean '='?}}
+ (void)x8;
+ int x9 <<= 0; // expected-error {{invalid '<<=' at end of declaration; did you mean '='?}}
+ (void)x9;
+ int x10 >= 0; // expected-error {{invalid '>=' at end of declaration; did you mean '='?}}
+ (void)x10;
+ int x11 >>= 0; // expected-error {{invalid '>>=' at end of declaration; did you mean '='?}}
+ (void)x11;
+ int x12 ^= 0; // expected-error {{invalid '^=' at end of declaration; did you mean '='?}}
+ (void)x12;
+ int x13 |= 0; // expected-error {{invalid '|=' at end of declaration; did you mean '='?}}
+ (void)x13;
+ int x14 == 0; // expected-error {{invalid '==' at end of declaration; did you mean '='?}}
+ (void)x14;
+ if (int x = 0) { (void)x; }
+ if (int x1 &= 0) { (void)x1; } // expected-error {{invalid '&=' at end of declaration; did you mean '='?}}
+ if (int x2 *= 0) { (void)x2; } // expected-error {{invalid '*=' at end of declaration; did you mean '='?}}
+ if (int x3 += 0) { (void)x3; } // expected-error {{invalid '+=' at end of declaration; did you mean '='?}}
+ if (int x4 -= 0) { (void)x4; } // expected-error {{invalid '-=' at end of declaration; did you mean '='?}}
+ if (int x5 != 0) { (void)x5; } // expected-error {{invalid '!=' at end of declaration; did you mean '='?}}
+ if (int x6 /= 0) { (void)x6; } // expected-error {{invalid '/=' at end of declaration; did you mean '='?}}
+ if (int x7 %= 0) { (void)x7; } // expected-error {{invalid '%=' at end of declaration; did you mean '='?}}
+ if (int x8 <= 0) { (void)x8; } // expected-error {{invalid '<=' at end of declaration; did you mean '='?}}
+ if (int x9 <<= 0) { (void)x9; } // expected-error {{invalid '<<=' at end of declaration; did you mean '='?}}
+ if (int x10 >= 0) { (void)x10; } // expected-error {{invalid '>=' at end of declaration; did you mean '='?}}
+ if (int x11 >>= 0) { (void)x11; } // expected-error {{invalid '>>=' at end of declaration; did you mean '='?}}
+ if (int x12 ^= 0) { (void)x12; } // expected-error {{invalid '^=' at end of declaration; did you mean '='?}}
+ if (int x13 |= 0) { (void)x13; } // expected-error {{invalid '|=' at end of declaration; did you mean '='?}}
+ if (int x14 == 0) { (void)x14; } // expected-error {{invalid '==' at end of declaration; did you mean '='?}}
+}
+}
+
+template <class A>
+class F1 {
+public:
+ template <int B>
+ class Iterator {
+ };
+};
+
+template<class T>
+class F2 {
+ typename F1<T>:: /*template*/ Iterator<0> Mypos; // expected-error {{use 'template' keyword to treat 'Iterator' as a dependent template name}}
+};
+
+template <class T>
+void f(){
+ typename F1<T>:: /*template*/ Iterator<0> Mypos; // expected-error {{use 'template' keyword to treat 'Iterator' as a dependent template name}}
+}
+
+// Tests for &/* fixits radar 7113438.
+class AD {};
+class BD: public AD {};
+
+void test (BD &br) {
+ AD* aPtr;
+ BD b;
+ aPtr = b; // expected-error {{assigning to 'AD *' from incompatible type 'BD'; take the address with &}}
+ aPtr = br; // expected-error {{assigning to 'AD *' from incompatible type 'BD'; take the address with &}}
+}
+
+void foo1() const {} // expected-error {{non-member function cannot have 'const' qualifier}}
+void foo2() volatile {} // expected-error {{non-member function cannot have 'volatile' qualifier}}
+void foo3() const volatile {} // expected-error {{non-member function cannot have 'const volatile' qualifier}}
+
+struct S { void f(int, char); };
+int itsAComma,
+itsAComma2 = 0,
+oopsAComma(42), // expected-error {{expected ';' at end of declaration}}
+AD oopsMoreCommas() {
+ static int n = 0, // expected-error {{expected ';' at end of declaration}}
+ static char c,
+ &d = c, // expected-error {{expected ';' at end of declaration}}
+ S s, // expected-error {{expected ';' at end of declaration}}
+ s.f(n, d);
+ AD ad, // expected-error {{expected ';' at end of declaration}}
+ return ad;
+}
+struct MoreAccidentalCommas {
+ int a : 5,
+ b : 7,
+ : 4, // expected-error {{expected ';' at end of declaration}}
+ char c, // expected-error {{expected ';' at end of declaration}}
+ double d, // expected-error {{expected ';' at end of declaration}}
+ MoreAccidentalCommas *next, // expected-error {{expected ';' at end of declaration}}
+public:
+ int k, // expected-error {{expected ';' at end of declaration}}
+ friend void f(MoreAccidentalCommas) {}
+ int k2, // expected-error {{expected ';' at end of declaration}}
+ virtual void g(), // expected-error {{expected ';' at end of declaration}}
+};
+
+template<class T> struct Mystery;
+template<class T> typedef Mystery<T>::type getMysteriousThing() { // \
+ expected-error {{function definition declared 'typedef'}} \
+ expected-error {{missing 'typename' prior to dependent}}
+ return Mystery<T>::get();
+}
+
+template<template<typename> Foo, // expected-error {{template template parameter requires 'class' after the parameter list}}
+ 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();
diff --git a/clang/test/FixIt/no-fixit.cpp b/clang/test/FixIt/no-fixit.cpp
new file mode 100644
index 0000000..c95c867
--- /dev/null
+++ b/clang/test/FixIt/no-fixit.cpp
@@ -0,0 +1,7 @@
+// RUN: %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
+
+// CHECK-NOT: fix-it:
+
+template<template<typename> +> void func();
diff --git a/clang/test/FixIt/no-macro-fixit.c b/clang/test/FixIt/no-macro-fixit.c
new file mode 100644
index 0000000..b6a9285
--- /dev/null
+++ b/clang/test/FixIt/no-macro-fixit.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -pedantic -fixit -x c %s
+// rdar://9091893
+
+#define va_arg(ap, type) __builtin_va_arg(ap, type)
+typedef __builtin_va_list va_list;
+
+void myFunc() {
+ va_list values;
+
+ int value;
+
+ while (value = va_arg(values, int)) { // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+ // expected-note {{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note {{place parentheses around the assignment to silence this warning}}
+ }
+}
diff --git a/clang/test/FixIt/no-typo.c b/clang/test/FixIt/no-typo.c
new file mode 100644
index 0000000..05947e8
--- /dev/null
+++ b/clang/test/FixIt/no-typo.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -fno-spell-checking -verify %s
+typedef struct {
+ float x, y;
+} Point;
+
+point p1; // expected-error{{unknown type name 'point'}}
diff --git a/clang/test/FixIt/objc-literals.m b/clang/test/FixIt/objc-literals.m
new file mode 100644
index 0000000..03d64b1
--- /dev/null
+++ b/clang/test/FixIt/objc-literals.m
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// 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 NSNumber (NSNumberCreation)
++ (NSNumber *)numberWithChar:(char)value;
++ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
++ (NSNumber *)numberWithShort:(short)value;
++ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
++ (NSNumber *)numberWithInt:(int)value;
++ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
++ (NSNumber *)numberWithLong:(long)value;
++ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
++ (NSNumber *)numberWithLongLong:(long long)value;
++ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
++ (NSNumber *)numberWithFloat:(float)value;
++ (NSNumber *)numberWithDouble:(double)value;
++ (NSNumber *)numberWithBool:(BOOL)value;
+@end
+
+@interface NSArray
+@end
+
+@interface NSArray (NSArrayCreation)
++ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
+@end
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
+@end
+
+void fixes() {
+ id arr = @[
+ 17, // expected-error{{numeric literal must be prefixed by '@' in a collection}}
+ 'a', // expected-error{{character literal must be prefixed by '@'}}
+ "blah" // expected-error{{string literal must be prefixed by '@'}}
+ ];
+}
diff --git a/clang/test/FixIt/typo-crash.cpp b/clang/test/FixIt/typo-crash.cpp
new file mode 100644
index 0000000..c154e3b
--- /dev/null
+++ b/clang/test/FixIt/typo-crash.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// FIXME: The diagnostics and recovery here are very, very poor.
+
+// PR10355
+template<typename T> void template_id1() { // expected-note {{'template_id1' declared here}} \
+ // expected-note {{possible target for call}}
+ template_id2<> t; // expected-error {{no template named 'template_id2'; did you mean 'template_id1'?}} \
+ // expected-error {{expected ';' after expression}} \
+ // expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}} \
+ // expected-error {{use of undeclared identifier 't'}}
+ }
+
+// FIXME: It would be nice if we could get this correction right.
+namespace PR12297 {
+ namespace A {
+ typedef short T;
+
+ namespace B {
+ typedef short T;
+
+ T global(); // expected-note {{'A::B::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'?}}
+}
diff --git a/clang/test/FixIt/typo-crash.m b/clang/test/FixIt/typo-crash.m
new file mode 100644
index 0000000..f10fe61
--- /dev/null
+++ b/clang/test/FixIt/typo-crash.m
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// <rdar://problem/7605289>
+@implementation Unknown (Blarg) // expected-error{{cannot find interface declaration for 'Unknown'}}
+- (int)method { return ivar; } // expected-error{{use of undeclared identifier 'ivar'}}
+@end
diff --git a/clang/test/FixIt/typo.c b/clang/test/FixIt/typo.c
new file mode 100644
index 0000000..0bafd1b
--- /dev/null
+++ b/clang/test/FixIt/typo.c
@@ -0,0 +1,37 @@
+// 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 "Rectangle" %t
+struct Point {
+ float x, y;
+};
+
+struct Rectangle {
+ struct Point top_left, // expected-note{{'top_left' declared here}}
+ bottom_right;
+};
+
+enum Color { Red, Green, Blue };
+
+struct Window {
+ struct Rectangle bounds; // expected-note{{'bounds' declared here}}
+ enum Color color;
+};
+
+struct Window window = {
+ .bunds. // expected-error{{field designator 'bunds' does not refer to any field in type 'struct Window'; did you mean 'bounds'?}}
+ topleft.x = 3.14, // expected-error{{field designator 'topleft' does not refer to any field in type 'struct Rectangle'; did you mean 'top_left'?}}
+ 2.71818, 5.0, 6.0, Red
+};
+
+void test() {
+ Rectangle r1; // expected-error{{must use 'struct' tag to refer to type 'Rectangle'}}
+ r1.top_left.x = 0;
+
+ typedef struct Rectangle Rectangle; // expected-note{{'Rectangle' declared here}}
+ rectangle *r2 = &r1; // expected-error{{unknown type name 'rectangle'; did you mean 'Rectangle'?}}
+ r2->top_left.y = 0;
+ unsinged *ptr = 0; // expected-error{{use of undeclared identifier 'unsinged'; did you mean 'unsigned'?}}
+ *ptr = 17;
+}
diff --git a/clang/test/FixIt/typo.cpp b/clang/test/FixIt/typo.cpp
new file mode 100644
index 0000000..3d40da8
--- /dev/null
+++ b/clang/test/FixIt/typo.cpp
@@ -0,0 +1,88 @@
+// 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 test_string %t
+
+namespace std {
+ template<typename T> class basic_string { // expected-note 2{{'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}}
+ };
+
+ typedef basic_string<char> string; // expected-note 2{{'string' declared here}}
+}
+
+namespace otherstd { // expected-note 2{{'otherstd' declared here}} \
+ // expected-note{{namespace 'otherstd' defined here}}
+ using namespace std;
+}
+
+using namespace std;
+
+other_std::strng str1; // expected-error{{use of undeclared identifier 'other_std'; did you mean 'otherstd'?}} \
+// expected-error{{no type named 'strng' in namespace 'otherstd'; did you mean 'string'?}}
+tring str2; // expected-error{{unknown type name 'tring'; did you mean 'string'?}}
+
+::other_std::string str3; // expected-error{{no member named 'other_std' in the global namespace; did you mean 'otherstd'?}}
+
+float area(float radius, // expected-note{{'radius' declared here}}
+ float pi) {
+ return radious * pi; // expected-error{{did you mean 'radius'?}}
+}
+
+using namespace othestd; // expected-error{{no namespace named 'othestd'; did you mean 'otherstd'?}}
+namespace blargh = otherstd; // expected-note 3{{namespace 'blargh' defined here}}
+using namespace ::blarg; // expected-error{{no namespace named 'blarg' in the global namespace; did you mean 'blargh'?}}
+
+namespace wibble = blarg; // expected-error{{no namespace named 'blarg'; did you mean 'blargh'?}}
+namespace wobble = ::blarg; // expected-error{{no namespace named 'blarg' in the global namespace; did you mean 'blargh'?}}
+
+bool test_string(std::string s) {
+ basc_string<char> b1; // expected-error{{no template named 'basc_string'; did you mean 'basic_string'?}}
+ std::basic_sting<char> b2; // expected-error{{no template named 'basic_sting' in namespace 'std'; did you mean 'basic_string'?}}
+ (void)b1;
+ (void)b2;
+ return s.fnd("hello") // expected-error{{no member named 'fnd' in 'std::basic_string<char>'; did you mean 'find'?}}
+ == std::string::pos; // expected-error{{no member named 'pos' in 'std::basic_string<char>'; did you mean 'npos'?}}
+}
+
+struct Base { };
+struct Derived : public Base { // expected-note{{base class 'Base' specified here}}
+ int member; // expected-note 3{{'member' declared here}}
+
+ Derived() : base(), // expected-error{{initializer 'base' does not name a non-static data member or base class; did you mean the base class 'Base'?}}
+ ember() { } // expected-error{{initializer 'ember' does not name a non-static data member or base class; did you mean the member 'member'?}}
+
+ int getMember() const {
+ return ember; // expected-error{{use of undeclared identifier 'ember'; did you mean 'member'?}}
+ }
+
+ int &getMember();
+};
+
+int &Derived::getMember() {
+ return ember; // expected-error{{use of undeclared identifier 'ember'; did you mean 'member'?}}
+}
+
+typedef int Integer; // expected-note{{'Integer' declared here}}
+int global_value; // expected-note{{'global_value' declared here}}
+
+int foo() {
+ integer * i = 0; // expected-error{{unknown type name 'integer'; did you mean 'Integer'?}}
+ unsinged *ptr = 0; // expected-error{{use of undeclared identifier 'unsinged'; did you mean 'unsigned'?}}
+ return *i + *ptr + global_val; // expected-error{{use of undeclared identifier 'global_val'; did you mean 'global_value'?}}
+}
+
+namespace nonstd {
+ typedef std::basic_string<char> yarn; // expected-note{{'nonstd::yarn' declared here}}
+}
+
+yarn str4; // expected-error{{unknown type name 'yarn'; did you mean 'nonstd::yarn'?}}
+
+namespace check_bool {
+ void f() {
+ Bool b; // expected-error{{use of undeclared identifier 'Bool'; did you mean 'bool'?}}
+ }
+}
diff --git a/clang/test/FixIt/typo.m b/clang/test/FixIt/typo.m
new file mode 100644
index 0000000..381233f
--- /dev/null
+++ b/clang/test/FixIt/typo.m
@@ -0,0 +1,167 @@
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -DNON_FIXITS -verify -Wno-objc-root-class %s
+// RUN: cp %s %t
+// RUN: not %clang_cc1 -x objective-c -fsyntax-only -triple x86_64-apple-darwin10 -fixit -Wno-objc-root-class %t
+// RUN: %clang_cc1 -x objective-c -fsyntax-only -triple x86_64-apple-darwin10 -pedantic -Werror -Wno-objc-root-class %t
+// RUN: grep "@implementation Sub3" %t
+
+@interface NSString // expected-note 2{{'NSString' declared here}}
++ (int)method:(int)x;
+@end
+
+void test() {
+ NSstring *str = @"A string"; // expected-error{{unknown type name 'NSstring'; did you mean 'NSString'?}}
+}
+
+@protocol P1
+@optional
+@property int *sprop; // expected-note{{'sprop' declared here}}
+@end
+
+@interface A
+{
+ int his_ivar; // expected-note 2{{'his_ivar' declared here}}
+ float wibble;
+}
+- (void)methodA;
++ (void)methodA;
+@property int his_prop; // expected-note{{'his_prop' declared here}}
+@end
+
+@interface B : A <P1>
+{
+ int her_ivar; // expected-note 2{{'her_ivar' declared here}}
+}
+
+@property int her_prop; // expected-note{{'her_prop' declared here}}
+- (void)inst_method1:(int)a;
++ (void)class_method1;
+@end
+
+@implementation A
+@synthesize his_prop = his_ivar;
+- (void)methodA { }
++ (void)methodA { }
+@end
+
+@implementation B
+@synthesize her_prop = her_ivar;
+
+-(void)inst_method1:(int)a {
+ herivar = a; // expected-error{{use of undeclared identifier 'herivar'; did you mean 'her_ivar'?}}
+ hisivar = a; // expected-error{{use of undeclared identifier 'hisivar'; did you mean 'his_ivar'?}}
+ self->herivar = a; // expected-error{{'B' does not have a member named 'herivar'; did you mean 'her_ivar'?}}
+ self->hisivar = a; // expected-error{{'B' does not have a member named 'hisivar'; did you mean 'his_ivar'?}}
+ self.hisprop = 0; // expected-error{{property 'hisprop' not found on object of type 'B *'; did you mean 'his_prop'?}}
+ self.herprop = 0; // expected-error{{property 'herprop' not found on object of type 'B *'; did you mean 'her_prop'?}}
+ self.s_prop = 0; // expected-error{{property 's_prop' not found on object of type 'B *'; did you mean 'sprop'?}}
+}
+
++(void)class_method1 {
+}
+@end
+
+void test_message_send(B* b) {
+ [NSstring method:17]; // expected-error{{unknown receiver 'NSstring'; did you mean 'NSString'?}}
+}
+
+@interface Collide // expected-note{{'Collide' declared here}}
+{
+@public
+ int value; // expected-note{{'value' declared here}}
+}
+
+@property int value; // expected-note{{'value' declared here}}
+@end
+
+@implementation Collide
+@synthesize value = value;
+@end
+
+void test2(Collide *a) {
+ a.valu = 17; // expected-error{{property 'valu' not found on object of type 'Collide *'; did you mean 'value'?}}
+ a->vale = 17; // expected-error{{'Collide' does not have a member named 'vale'; did you mean 'value'?}}
+}
+
+#ifdef NON_FIXITS
+@interface Derived : Collid // expected-error{{cannot find interface declaration for 'Collid', superclass of 'Derived'; did you mean 'Collide'?}}
+@end
+#endif
+
+#ifdef NON_FIXITS
+@protocol NetworkSocket // expected-note{{'NetworkSocket' declared here}}
+- (int)send:(void*)buffer bytes:(int)bytes;
+@end
+
+@interface IPv6 <Network_Socket> // expected-error{{cannot find protocol declaration for 'Network_Socket'; did you mean 'NetworkSocket'?}}
+@end
+#endif
+
+@interface Super
+- (int)method; // expected-note{{using}}
+- (int)method2;
+- (int)method3:(id)x;
+@end
+
+@interface Sub : Super
+- (int)method;
+@end
+
+@implementation Sub
+- (int)method {
+ return [supper method]; // expected-error{{unknown receiver 'supper'; did you mean 'super'?}}
+}
+
+@end
+
+double *isupper(int);
+
+@interface Sub2 : Super
+- (int)method2;
+@end
+
+@implementation Sub2
+- (int)method2 {
+ return [supper method2]; // expected-error{{unknown receiver 'supper'; did you mean 'super'?}}
+}
+@end
+
+@interface Ivar
+@end
+
+@protocol Proto
+@property (retain) id ivar;
+@end
+
+#ifdef NON_FIXITS
+@interface User <Proto>
+- (void)method; // expected-note{{also found}}
+@end
+
+@implementation User
+@synthesize ivar;
+
+- (void)method {
+ // Test that we don't correct 'ivar' to 'Ivar' e
+ [ivar method]; // expected-warning{{multiple methods named 'method' found}}
+}
+@end
+#endif
+
+void f(A *a) {
+ f(a) // expected-error{{expected ';' after expression}}
+ [a methodA] // expected-error{{expected ';' after expression}}
+ [A methodA] // expected-error{{expected ';' after expression}}
+}
+
+#ifdef NON_FIXITS
+@interface Sub3 : Super
+- (int)method3;
+@end
+
+@implementation Sub3
+- (int)method3 {
+ int x = super; // expected-error{{use of undeclared identifier 'super'}}
+ return 0;
+}
+@end
+#endif