diff options
Diffstat (limited to 'test/Misc/caret-diags-macros.c')
-rw-r--r-- | test/Misc/caret-diags-macros.c | 79 |
1 files changed, 62 insertions, 17 deletions
diff --git a/test/Misc/caret-diags-macros.c b/test/Misc/caret-diags-macros.c index de1ee76..5faddb6 100644 --- a/test/Misc/caret-diags-macros.c +++ b/test/Misc/caret-diags-macros.c @@ -1,13 +1,13 @@ -// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s -strict-whitespace #define M1(x) x #define M2 1; void foo() { M1( M2); - // CHECK: :7:{{[0-9]+}}: warning: expression result unused - // CHECK: :4:{{[0-9]+}}: note: expanded from macro 'M2' - // CHECK: :3:{{[0-9]+}}: note: expanded from macro 'M1' + // CHECK: {{.*}}:7:{{[0-9]+}}: warning: expression result unused + // CHECK: {{.*}}:4:{{[0-9]+}}: note: expanded from macro 'M2' + // CHECK: {{.*}}:3:{{[0-9]+}}: note: expanded from macro 'M1' } #define A 1 @@ -15,10 +15,10 @@ void foo() { #define C B void bar() { C; - // CHECK: :17:3: warning: expression result unused - // CHECK: :15:11: note: expanded from macro 'C' - // CHECK: :14:11: note: expanded from macro 'B' - // CHECK: :13:11: note: expanded from macro 'A' + // CHECK: {{.*}}:17:3: warning: expression result unused + // CHECK: {{.*}}:15:11: note: expanded from macro 'C' + // CHECK: {{.*}}:14:11: note: expanded from macro 'B' + // CHECK: {{.*}}:13:11: note: expanded from macro 'A' } // rdar://7597492 @@ -40,12 +40,12 @@ void baz(char *Msg) { #define macro_many_args3(x, y, z) macro_many_args2(x, y, z) void test() { - macro_args3(1); + macro_args3(11); // 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-NEXT: macro_args3(11); + // CHECK-NEXT: {{^ \^~}} // CHECK: {{.*}}:36:36: note: expanded from macro 'macro_args3' // CHECK: {{.*}}:35:36: note: expanded from macro 'macro_args2' // CHECK: {{.*}}:34:24: note: expanded from macro 'macro_args1' @@ -71,13 +71,13 @@ void test() { macro_many_args3( 1, - macro_args2(2), + macro_args2(22), 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-NEXT: macro_args2(22), + // CHECK-NEXT: {{^ \^~}} // CHECK: {{.*}}:35:36: note: expanded from macro 'macro_args2' // CHECK: {{.*}}:34:24: note: expanded from macro 'macro_args1' // CHECK: {{.*}}:40:55: note: expanded from macro 'macro_many_args3' @@ -90,10 +90,10 @@ void test() { #define variadic_args3(x, y, ...) variadic_args2(x, y, __VA_ARGS__) void test2() { - variadic_args3(1, 2, 3, 4); + variadic_args3(1, 22, 3, 4); // CHECK: {{.*}}:93:21: warning: expression result unused - // CHECK-NEXT: variadic_args3(1, 2, 3, 4); - // CHECK-NEXT: ~~~~~~~~~~~~~~~~~~^~~~~~~~ + // CHECK-NEXT: variadic_args3(1, 22, 3, 4); + // CHECK-NEXT: {{^ \^~}} // CHECK: {{.*}}:90:53: note: expanded from macro 'variadic_args3' // CHECK: {{.*}}:89:50: note: expanded from macro 'variadic_args2' // CHECK: {{.*}}:88:35: note: expanded from macro 'variadic_args1' @@ -118,3 +118,48 @@ void test3() { // CHECK: {{.*}}:104:70: note: expanded from macro 'variadic_pasting_args2a' // CHECK: {{.*}}:102:41: note: expanded from macro 'variadic_pasting_args1' } + +#define BAD_CONDITIONAL_OPERATOR (2<3)?2:3 +int test4 = BAD_CONDITIONAL_OPERATOR+BAD_CONDITIONAL_OPERATOR; +// CHECK: {{.*}}:122:39: note: expanded from macro 'BAD_CONDITIONAL_OPERATOR' +// CHECK-NEXT: #define BAD_CONDITIONAL_OPERATOR (2<3)?2:3 +// CHECK-NEXT: {{^ \^}} +// CHECK: {{.*}}:122:39: note: expanded from macro 'BAD_CONDITIONAL_OPERATOR' +// CHECK-NEXT: #define BAD_CONDITIONAL_OPERATOR (2<3)?2:3 +// CHECK-NEXT: {{^ \^}} +// CHECK: {{.*}}:122:39: note: expanded from macro 'BAD_CONDITIONAL_OPERATOR' +// CHECK-NEXT: #define BAD_CONDITIONAL_OPERATOR (2<3)?2:3 +// CHECK-NEXT: {{^ ~~~~~\^~~~}} + +#define QMARK ? +#define TWOL (2< +#define X 1+TWOL 3) QMARK 4:5 +int x = X; +// CHECK: {{.*}}:137:9: note: place parentheses around the '+' expression to silence this warning +// CHECK-NEXT: int x = X; +// CHECK-NEXT: {{^ \^}} +// CHECK-NEXT: {{.*}}:136:21: note: expanded from macro 'X' +// CHECK-NEXT: #define X 1+TWOL 3) QMARK 4:5 +// CHECK-NEXT: {{^ ~~~~~~~~~ \^}} +// CHECK-NEXT: {{.*}}:134:15: note: expanded from macro 'QMARK' +// CHECK-NEXT: #define QMARK ? +// CHECK-NEXT: {{^ \^}} +// CHECK-NEXT: {{.*}}:137:9: note: place parentheses around the '?:' expression to evaluate it first +// CHECK-NEXT: int x = X; +// CHECK-NEXT: {{^ \^}} +// CHECK-NEXT: {{.*}}:136:21: note: expanded from macro 'X' +// CHECK-NEXT: #define X 1+TWOL 3) QMARK 4:5 +// CHECK-NEXT: {{^ ~~~~~~~~\^~~~~~~~~}} + +#define ONEPLUS 1+ +#define Y ONEPLUS (2<3) QMARK 4:5 +int y = Y; +// CHECK: {{.*}}:156:9: warning: operator '?:' has lower precedence than '+'; '+' will be evaluated first +// CHECK-NEXT: int y = Y; +// CHECK-NEXT: {{^ \^}} +// CHECK-NEXT: {{.*}}:155:25: note: expanded from macro 'Y' +// CHECK-NEXT: #define Y ONEPLUS (2<3) QMARK 4:5 +// CHECK-NEXT: {{^ ~~~~~~~~~~~~~ \^}} +// CHECK-NEXT: {{.*}}:134:15: note: expanded from macro 'QMARK' +// CHECK-NEXT: #define QMARK ? +// CHECK-NEXT: {{^ \^}} |