summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/test')
-rw-r--r--clang-tools-extra/test/cpp11-migrate/UseAuto/new.cpp52
-rw-r--r--clang-tools-extra/test/cpp11-migrate/UseAuto/new_cv_failing.cpp36
2 files changed, 88 insertions, 0 deletions
diff --git a/clang-tools-extra/test/cpp11-migrate/UseAuto/new.cpp b/clang-tools-extra/test/cpp11-migrate/UseAuto/new.cpp
new file mode 100644
index 00000000000..911c0cd76bd
--- /dev/null
+++ b/clang-tools-extra/test/cpp11-migrate/UseAuto/new.cpp
@@ -0,0 +1,52 @@
+// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
+// RUN: cpp11-migrate -use-auto %t.cpp -- -std=c++11
+// RUN: FileCheck -input-file=%t.cpp %s
+
+class MyType {
+};
+
+class MyDerivedType : public MyType {
+};
+
+int main(int argc, char **argv) {
+ MyType *a = new MyType();
+ // CHECK: auto a = new MyType();
+
+ static MyType *a_static = new MyType();
+ // CHECK: static auto a_static = new MyType();
+
+ MyType *b = new MyDerivedType();
+ // CHECK: MyType *b = new MyDerivedType();
+
+ void *c = new MyType();
+ // CHECK: void *c = new MyType();
+
+ // CV-qualifier tests.
+ //
+ // NOTE : the form "type const" is expected here because of a deficiency in
+ // TypeLoc where CV qualifiers are not considered part of the type location
+ // info. That is, all that is being replaced in each case is "MyType *" and
+ // not "MyType * const".
+ {
+ static MyType * const d_static = new MyType();
+ // CHECK: static auto const d_static = new MyType();
+
+ MyType * const d3 = new MyType();
+ // CHECK: auto const d3 = new MyType();
+
+ MyType * volatile d4 = new MyType();
+ // CHECK: auto volatile d4 = new MyType();
+ }
+
+ int (**func)(int, int) = new (int(*[5])(int,int));
+ // CHECK: int (**func)(int, int) = new (int(*[5])(int,int));
+
+ int *e = new int[5];
+ // CHECK: auto e = new int[5];
+
+ MyType *f(new MyType);
+ // CHECK: auto f(new MyType);
+
+ MyType *g{new MyType};
+ // CHECK: MyType *g{new MyType};
+}
diff --git a/clang-tools-extra/test/cpp11-migrate/UseAuto/new_cv_failing.cpp b/clang-tools-extra/test/cpp11-migrate/UseAuto/new_cv_failing.cpp
new file mode 100644
index 00000000000..8e21018ef90
--- /dev/null
+++ b/clang-tools-extra/test/cpp11-migrate/UseAuto/new_cv_failing.cpp
@@ -0,0 +1,36 @@
+// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
+// RUN: cpp11-migrate -use-auto %t.cpp -- -std=c++11
+// RUN: FileCheck -input-file=%t.cpp %s
+// XFAIL: *
+
+// None of these tests can pass right now because TypeLoc information where CV
+// qualifiers are concerned is not reliable/available.
+
+class MyType {
+};
+
+int main (int argc, char **argv) {
+ const MyType *d = new MyType();
+ // CHECK: const auto *d = new MyType();
+
+ volatile MyType *d2 = new MyType();
+ // CHECK: volatile auto *d2 = new MyType();
+
+ const MyType * volatile e = new MyType();
+ // CHECK: const auto * volatile d = new MyType();
+
+ volatile MyType * const f = new MyType();
+ // CHECK: volatile auto * const d2 = new MyType();
+
+ const MyType *d5 = new const MyType();
+ // CHECK: auto d5 = new const MyType();
+
+ volatile MyType *d6 = new volatile MyType();
+ // CHECK: auto d6 = new volatile MyType();
+
+ const MyType * const d7 = new const MyType();
+ // CHECK: const auto d7 = new const MyType();
+
+ volatile MyType * volatile d8 = new volatile MyType();
+ // CHECK: volatile auto d8 = new volatile MyType();
+}
OpenPOWER on IntegriCloud