summaryrefslogtreecommitdiffstats
path: root/test/Misc
diff options
context:
space:
mode:
Diffstat (limited to 'test/Misc')
-rw-r--r--test/Misc/caret-diags-macros.c107
-rw-r--r--test/Misc/diag-aka-types.cpp38
-rw-r--r--test/Misc/include-stack-for-note-flag.cpp4
-rw-r--r--test/Misc/macro-backtrace-limit.c12
4 files changed, 145 insertions, 16 deletions
diff --git a/test/Misc/caret-diags-macros.c b/test/Misc/caret-diags-macros.c
index e45ad2a..ac83ecc 100644
--- a/test/Misc/caret-diags-macros.c
+++ b/test/Misc/caret-diags-macros.c
@@ -5,9 +5,9 @@
void foo() {
M1(
M2);
- // CHECK: {{.*}}:6:{{[0-9]+}}: warning: expression result unused
- // CHECK: {{.*}}:7:{{[0-9]+}}: note: instantiated from:
- // CHECK: {{.*}}:4:{{[0-9]+}}: note: instantiated from:
+ // CHECK: :7:{{[0-9]+}}: warning: expression result unused
+ // CHECK: :4:{{[0-9]+}}: note: expanded from:
+ // CHECK: :3:{{[0-9]+}}: note: expanded from:
}
#define A 1
@@ -15,13 +15,12 @@ void foo() {
#define C B
void bar() {
C;
- // CHECK: {{.*}}:17:{{[0-9]+}}: warning: expression result unused
- // CHECK: {{.*}}:15:{{[0-9]+}}: note: instantiated from:
- // CHECK: {{.*}}:14:{{[0-9]+}}: note: instantiated from:
- // CHECK: {{.*}}:13:{{[0-9]+}}: note: instantiated from:
+ // CHECK: :17:3: warning: expression result unused
+ // CHECK: :15:11: note: expanded from:
+ // CHECK: :14:11: note: expanded from:
+ // CHECK: :13:11: note: expanded from:
}
-
// rdar://7597492
#define sprintf(str, A, B) \
__builtin___sprintf_chk (str, 0, 42, A, B)
@@ -30,3 +29,95 @@ void baz(char *Msg) {
sprintf(Msg, " sizeof FoooLib : =%3u\n", 12LL);
}
+
+// PR9279: comprehensive tests for multi-level macro back traces
+#define macro_args1(x) x
+#define macro_args2(x) macro_args1(x)
+#define macro_args3(x) macro_args2(x)
+
+#define macro_many_args1(x, y, z) y
+#define macro_many_args2(x, y, z) macro_many_args1(x, y, z)
+#define macro_many_args3(x, y, z) macro_many_args2(x, y, z)
+
+void test() {
+ macro_args3(1);
+ // CHECK: {{.*}}:43:15: warning: expression result unused
+ // Also check that the 'caret' printing agrees with the location here where
+ // its easy to FileCheck.
+ // CHECK-NEXT: macro_args3(1);
+ // CHECK-NEXT: ~~~~~~~~~~~~^~
+ // CHECK: {{.*}}:36:36: note: expanded from:
+ // CHECK: {{.*}}:35:36: note: expanded from:
+ // CHECK: {{.*}}:34:24: note: expanded from:
+
+ macro_many_args3(
+ 1,
+ 2,
+ 3);
+ // CHECK: {{.*}}:55:5: warning: expression result unused
+ // CHECK: {{.*}}:40:55: note: expanded from:
+ // CHECK: {{.*}}:39:55: note: expanded from:
+ // CHECK: {{.*}}:38:35: note: expanded from:
+
+ macro_many_args3(
+ 1,
+ M2,
+ 3);
+ // CHECK: {{.*}}:64:5: warning: expression result unused
+ // CHECK: {{.*}}:4:12: note: expanded from:
+ // CHECK: {{.*}}:40:55: note: expanded from:
+ // CHECK: {{.*}}:39:55: note: expanded from:
+ // CHECK: {{.*}}:38:35: note: expanded from:
+
+ macro_many_args3(
+ 1,
+ macro_args2(2),
+ 3);
+ // CHECK: {{.*}}:74:17: warning: expression result unused
+ // This caret location needs to be printed *inside* a different macro's
+ // arguments.
+ // CHECK-NEXT: macro_args2(2),
+ // CHECK-NEXT: ~~~~~~~~~~~~^~~
+ // CHECK: {{.*}}:35:36: note: expanded from:
+ // CHECK: {{.*}}:34:24: note: expanded from:
+ // CHECK: {{.*}}:40:55: note: expanded from:
+ // CHECK: {{.*}}:39:55: note: expanded from:
+ // CHECK: {{.*}}:38:35: note: expanded from:
+}
+
+#define variadic_args1(x, y, ...) y
+#define variadic_args2(x, ...) variadic_args1(x, __VA_ARGS__)
+#define variadic_args3(x, y, ...) variadic_args2(x, y, __VA_ARGS__)
+
+void test2() {
+ variadic_args3(1, 2, 3, 4);
+ // CHECK: {{.*}}:93:21: warning: expression result unused
+ // CHECK-NEXT: variadic_args3(1, 2, 3, 4);
+ // CHECK-NEXT: ~~~~~~~~~~~~~~~~~~^~~~~~~~
+ // CHECK: {{.*}}:90:53: note: expanded from:
+ // CHECK: {{.*}}:89:50: note: expanded from:
+ // CHECK: {{.*}}:88:35: note: expanded from:
+}
+
+#define variadic_pasting_args1(x, y, z) y
+#define variadic_pasting_args2(x, ...) variadic_pasting_args1(x ## __VA_ARGS__)
+#define variadic_pasting_args2a(x, y, ...) variadic_pasting_args1(x, y ## __VA_ARGS__)
+#define variadic_pasting_args3(x, y, ...) variadic_pasting_args2(x, y, __VA_ARGS__)
+#define variadic_pasting_args3a(x, y, ...) variadic_pasting_args2a(x, y, __VA_ARGS__)
+
+void test3() {
+ variadic_pasting_args3(1, 2, 3, 4);
+ // CHECK: {{.*}}:109:32: warning: expression result unused
+ // CHECK: {{.*}}:105:72: note: expanded from:
+ // CHECK: {{.*}}:103:68: note: expanded from:
+ // CHECK: {{.*}}:102:41: note: expanded from:
+
+ variadic_pasting_args3a(1, 2, 3, 4);
+ // FIXME: It'd be really nice to retain the start location of the first token
+ // involved in the token paste instead of falling back on the full macro
+ // location in the first two locations here.
+ // CHECK: {{.*}}:115:3: warning: expression result unused
+ // CHECK: {{.*}}:106:44: note: expanded from:
+ // CHECK: {{.*}}:104:72: note: expanded from:
+ // CHECK: {{.*}}:102:41: note: expanded from:
+}
diff --git a/test/Misc/diag-aka-types.cpp b/test/Misc/diag-aka-types.cpp
index e0e6b8c..042c70b 100644
--- a/test/Misc/diag-aka-types.cpp
+++ b/test/Misc/diag-aka-types.cpp
@@ -12,3 +12,41 @@ char c2 = ref; // expected-error{{'const foo_t' (aka 'const X')}}
// deduced auto should not produce an aka.
auto aut = X();
char c3 = aut; // expected-error{{from 'X' to 'char'}}
+
+// There are two classes named Foo::foo here. Make sure the message gives
+// a way to them apart.
+namespace Foo {
+ class foo {};
+}
+
+namespace bar {
+ namespace Foo {
+ class foo;
+ }
+ void f(Foo::foo* x); // expected-note{{passing argument to parameter 'x' here}}
+}
+
+void test(Foo::foo* x) {
+ bar::f(x); // expected-error{{cannot initialize a parameter of type 'Foo::foo *' (aka 'bar::Foo::foo *') with an lvalue of type 'Foo::foo *')}}
+}
+
+// PR9548 - "no known conversion from 'vector<string>' to 'vector<string>'"
+// vector<string> refers to two different types here. Make sure the message
+// gives a way to tell them apart.
+class versa_string;
+typedef versa_string string;
+
+namespace std {template <typename T> class vector;}
+using std::vector;
+
+void f(vector<string> v); // expected-note {{candidate function not viable: no known conversion from 'vector<string>' (aka 'std::vector<std::basic_string>') to 'vector<string>' (aka 'std::vector<versa_string>') for 1st argument}}
+
+namespace std {
+ class basic_string;
+ typedef basic_string string;
+ template <typename T> class vector {};
+ void g() {
+ vector<string> v;
+ f(v); // expected-error{{no matching function for call to 'f'}}
+ }
+}
diff --git a/test/Misc/include-stack-for-note-flag.cpp b/test/Misc/include-stack-for-note-flag.cpp
index 328999d..cfec506 100644
--- a/test/Misc/include-stack-for-note-flag.cpp
+++ b/test/Misc/include-stack-for-note-flag.cpp
@@ -18,11 +18,11 @@ bool macro(int x, int y) {
// STACK: note: candidate function not viable
// STACK: error: comparison between pointer and integer
// STACK: In file included from
-// STACK: note: instantiated from:
+// STACK: note: expanded from:
// STACKLESS: error: no matching function for call to 'foo'
// STACKLESS-NOT: In file included from
// STACKLESS: note: candidate function not viable
// STACKLESS: error: comparison between pointer and integer
// STACKLESS-NOT: In file included from
-// STACKLESS: note: instantiated from:
+// STACKLESS: note: expanded from:
diff --git a/test/Misc/macro-backtrace-limit.c b/test/Misc/macro-backtrace-limit.c
index 1e512fe..ee73c61 100644
--- a/test/Misc/macro-backtrace-limit.c
+++ b/test/Misc/macro-backtrace-limit.c
@@ -17,16 +17,16 @@
void f(int *ip, float *fp) {
// CHECK: macro-backtrace-limit.c:31:7: warning: comparison of distinct pointer types ('int *' and 'float *')
// CHECK: if (M12(ip, fp)) { }
- // CHECK: macro-backtrace-limit.c:15:19: note: instantiated from:
+ // CHECK: macro-backtrace-limit.c:15:19: note: expanded from:
// CHECK: #define M12(A, B) M11(A, B)
- // CHECK: macro-backtrace-limit.c:14:19: note: instantiated from:
+ // CHECK: macro-backtrace-limit.c:14:19: note: expanded from:
// CHECK: #define M11(A, B) M10(A, B)
- // CHECK: note: (skipping 7 contexts in backtrace; use -fmacro-backtrace-limit=0 to see all)
- // CHECK: macro-backtrace-limit.c:6:18: note: instantiated from:
+ // CHECK: note: (skipping 7 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
+ // CHECK: macro-backtrace-limit.c:6:18: note: expanded from:
// CHECK: #define M3(A, B) M2(A, B)
- // CHECK: macro-backtrace-limit.c:5:18: note: instantiated from:
+ // CHECK: macro-backtrace-limit.c:5:18: note: expanded from:
// CHECK: #define M2(A, B) M1(A, B)
- // CHECK: macro-backtrace-limit.c:4:23: note: instantiated from:
+ // CHECK: macro-backtrace-limit.c:4:23: note: expanded from:
// CHECK: #define M1(A, B) ((A) < (B))
if (M12(ip, fp)) { }
}
OpenPOWER on IntegriCloud