summaryrefslogtreecommitdiffstats
path: root/test/FixIt
diff options
context:
space:
mode:
Diffstat (limited to 'test/FixIt')
-rw-r--r--test/FixIt/fixit-at.c5
-rw-r--r--test/FixIt/fixit-c90.c11
-rw-r--r--test/FixIt/fixit-errors-1.c13
-rw-r--r--test/FixIt/fixit-errors.c10
-rw-r--r--test/FixIt/fixit-objc.m8
-rw-r--r--test/FixIt/fixit.c29
-rw-r--r--test/FixIt/fixit.cpp29
7 files changed, 105 insertions, 0 deletions
diff --git a/test/FixIt/fixit-at.c b/test/FixIt/fixit-at.c
new file mode 100644
index 0000000..42488f5
--- /dev/null
+++ b/test/FixIt/fixit-at.c
@@ -0,0 +1,5 @@
+// RUN: clang-cc -fsyntax-only -fixit-at=fixit-at.c:3:1 %s -o - | clang-cc -verify -x c -
+
+_Complex cd;
+
+int i0[1] = { { 17 } }; // expected-warning{{braces}}
diff --git a/test/FixIt/fixit-c90.c b/test/FixIt/fixit-c90.c
new file mode 100644
index 0000000..03c9495
--- /dev/null
+++ b/test/FixIt/fixit-c90.c
@@ -0,0 +1,11 @@
+/* RUN: clang-cc -fsyntax-only -std=c90 -pedantic -fixit %s -o - | clang-cc -pedantic -x c -std=c90 -Werror -
+ */
+
+/* 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/test/FixIt/fixit-errors-1.c b/test/FixIt/fixit-errors-1.c
new file mode 100644
index 0000000..14329ea
--- /dev/null
+++ b/test/FixIt/fixit-errors-1.c
@@ -0,0 +1,13 @@
+// RUN: clang-cc -fsyntax-only -pedantic -fixit %s -o - | clang-cc -pedantic -Werror -x c -
+
+/* 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/test/FixIt/fixit-errors.c b/test/FixIt/fixit-errors.c
new file mode 100644
index 0000000..9c5258d
--- /dev/null
+++ b/test/FixIt/fixit-errors.c
@@ -0,0 +1,10 @@
+// RUN: clang-cc -fsyntax-only -pedantic -fixit %s -o - | clang-cc -pedantic -Werror -x c -
+
+/* 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}}
diff --git a/test/FixIt/fixit-objc.m b/test/FixIt/fixit-objc.m
new file mode 100644
index 0000000..baef233
--- /dev/null
+++ b/test/FixIt/fixit-objc.m
@@ -0,0 +1,8 @@
+// RUN: clang-cc -fsyntax-only -fixit-at=fixit-at.c:3:1 %s -o %t.m &&
+// RUN: clang-cc -verify %t.m
+
+@protocol X;
+
+void foo() {
+ <X> *P; // should be fixed to 'id<X>'.
+}
diff --git a/test/FixIt/fixit.c b/test/FixIt/fixit.c
new file mode 100644
index 0000000..1378df4
--- /dev/null
+++ b/test/FixIt/fixit.c
@@ -0,0 +1,29 @@
+// RUN: clang-cc -fsyntax-only -pedantic -fixit %s -o - | clang-cc -pedantic -Werror -x c -
+
+/* 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. */
+#include <string.h> // FIXME: FIX-IT hint should add this for us!
+
+void f0(void) { };
+
+struct s {
+ int x, y;;
+};
+
+_Complex cd;
+
+struct s s0 = { y: 5 };
+int array0[5] = { [3] 3 };
+
+void f1(x, y)
+{
+}
+
+int i0 = { 17 };
+
+int f2(const char *my_string) {
+ // FIXME: terminal output isn't so good when "my_string" is shorter
+ return my_string == "foo";
+}
diff --git a/test/FixIt/fixit.cpp b/test/FixIt/fixit.cpp
new file mode 100644
index 0000000..ccddd95
--- /dev/null
+++ b/test/FixIt/fixit.cpp
@@ -0,0 +1,29 @@
+// RUN: clang-cc -fsyntax-only -pedantic -fixit %s -o - | clang-cc -fsyntax-only -pedantic -Werror -x c++ -
+
+/* 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<> class CT<1> { }; // expected-error{{tag type}}
OpenPOWER on IntegriCloud