Chandler Carruth | 1aaddf2 | 2011-10-16 07:20:21 +0000 | [diff] [blame] | 1 | // Tests for macro expansion backtraces. The RUN and CHECK lines are grouped |
| 2 | // below the test code to reduce noise when updating them. |
Douglas Gregor | 6c1cb99 | 2010-05-04 17:13:42 +0000 | [diff] [blame] | 3 | |
| 4 | #define M1(A, B) ((A) < (B)) |
| 5 | #define M2(A, B) M1(A, B) |
| 6 | #define M3(A, B) M2(A, B) |
| 7 | #define M4(A, B) M3(A, B) |
| 8 | #define M5(A, B) M4(A, B) |
| 9 | #define M6(A, B) M5(A, B) |
| 10 | #define M7(A, B) M6(A, B) |
| 11 | #define M8(A, B) M7(A, B) |
| 12 | #define M9(A, B) M8(A, B) |
| 13 | #define M10(A, B) M9(A, B) |
| 14 | #define M11(A, B) M10(A, B) |
| 15 | #define M12(A, B) M11(A, B) |
| 16 | |
| 17 | void f(int *ip, float *fp) { |
Chandler Carruth | 1aaddf2 | 2011-10-16 07:20:21 +0000 | [diff] [blame] | 18 | if (M12(ip, fp)) { } |
Chandler Carruth | e0376c0 | 2011-10-16 07:20:23 +0000 | [diff] [blame] | 19 | // RUN: %clang_cc1 -fsyntax-only -fmacro-backtrace-limit 5 %s 2>&1 \ |
| 20 | // RUN: | FileCheck %s -check-prefix=CHECK-LIMIT |
| 21 | // CHECK-LIMIT: macro-backtrace.c:18:7: warning: comparison of distinct pointer types ('int *' and 'float *') |
| 22 | // CHECK-LIMIT: if (M12(ip, fp)) { } |
Chandler Carruth | a47129e | 2011-10-16 09:30:08 +0000 | [diff] [blame] | 23 | // CHECK-LIMIT: macro-backtrace.c:15:19: note: expanded from macro: M12 |
Chandler Carruth | e0376c0 | 2011-10-16 07:20:23 +0000 | [diff] [blame] | 24 | // CHECK-LIMIT: #define M12(A, B) M11(A, B) |
Chandler Carruth | a47129e | 2011-10-16 09:30:08 +0000 | [diff] [blame] | 25 | // CHECK-LIMIT: macro-backtrace.c:14:19: note: expanded from macro: M11 |
Chandler Carruth | e0376c0 | 2011-10-16 07:20:23 +0000 | [diff] [blame] | 26 | // CHECK-LIMIT: #define M11(A, B) M10(A, B) |
| 27 | // CHECK-LIMIT: note: (skipping 7 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) |
Chandler Carruth | a47129e | 2011-10-16 09:30:08 +0000 | [diff] [blame] | 28 | // CHECK-LIMIT: macro-backtrace.c:6:18: note: expanded from macro: M3 |
Chandler Carruth | e0376c0 | 2011-10-16 07:20:23 +0000 | [diff] [blame] | 29 | // CHECK-LIMIT: #define M3(A, B) M2(A, B) |
Chandler Carruth | a47129e | 2011-10-16 09:30:08 +0000 | [diff] [blame] | 30 | // CHECK-LIMIT: macro-backtrace.c:5:18: note: expanded from macro: M2 |
Chandler Carruth | e0376c0 | 2011-10-16 07:20:23 +0000 | [diff] [blame] | 31 | // CHECK-LIMIT: #define M2(A, B) M1(A, B) |
Chandler Carruth | a47129e | 2011-10-16 09:30:08 +0000 | [diff] [blame] | 32 | // CHECK-LIMIT: macro-backtrace.c:4:23: note: expanded from macro: M1 |
Chandler Carruth | e0376c0 | 2011-10-16 07:20:23 +0000 | [diff] [blame] | 33 | // CHECK-LIMIT: #define M1(A, B) ((A) < (B)) |
Chandler Carruth | 4ba5565 | 2011-10-16 07:20:28 +0000 | [diff] [blame] | 34 | |
Chandler Carruth | 4ba5565 | 2011-10-16 07:20:28 +0000 | [diff] [blame] | 35 | // RUN: %clang_cc1 -fsyntax-only -fno-caret-diagnostics %s 2>&1 \ |
| 36 | // RUN: | FileCheck %s -check-prefix=CHECK-NO-CARETS |
| 37 | // CHECK-NO-CARETS: macro-backtrace.c:18:7: warning: comparison of distinct pointer types ('int *' and 'float *') |
Chandler Carruth | a47129e | 2011-10-16 09:30:08 +0000 | [diff] [blame] | 38 | // CHECK-NO-CARETS-NEXT: macro-backtrace.c:15:19: note: expanded from macro: M12 |
| 39 | // CHECK-NO-CARETS-NEXT: macro-backtrace.c:14:19: note: expanded from macro: M11 |
| 40 | // CHECK-NO-CARETS-NEXT: macro-backtrace.c:13:19: note: expanded from macro: M10 |
Chandler Carruth | 4ba5565 | 2011-10-16 07:20:28 +0000 | [diff] [blame] | 41 | // CHECK-NO-CARETS-NEXT: note: (skipping 6 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) |
Chandler Carruth | a47129e | 2011-10-16 09:30:08 +0000 | [diff] [blame] | 42 | // CHECK-NO-CARETS-NEXT: macro-backtrace.c:6:18: note: expanded from macro: M3 |
| 43 | // CHECK-NO-CARETS-NEXT: macro-backtrace.c:5:18: note: expanded from macro: M2 |
| 44 | // CHECK-NO-CARETS-NEXT: macro-backtrace.c:4:23: note: expanded from macro: M1 |
Chandler Carruth | 4c3fd51 | 2011-10-16 21:33:06 +0000 | [diff] [blame^] | 45 | |
| 46 | // Check that the expansion notes respect the same formatting options as |
| 47 | // other diagnostics. |
| 48 | // RUN: %clang_cc1 -fsyntax-only -fdiagnostics-format vi %s 2>&1 \ |
| 49 | // RUN: | FileCheck %s -check-prefix=CHECK-NOTE-FORMAT |
| 50 | // CHECK-NOTE-FORMAT: macro-backtrace.c +18:7: warning: |
| 51 | // CHECK-NOTE-FORMAT: macro-backtrace.c +15:19: note: |
| 52 | // CHECK-NOTE-FORMAT: macro-backtrace.c +14:19: note: |
| 53 | // CHECK-NOTE-FORMAT: note: |
| 54 | // CHECK-NOTE-FORMAT: macro-backtrace.c +6:18: note: |
| 55 | // CHECK-NOTE-FORMAT: macro-backtrace.c +5:18: note: |
| 56 | // CHECK-NOTE-FORMAT: macro-backtrace.c +4:23: note: |
Douglas Gregor | 6c1cb99 | 2010-05-04 17:13:42 +0000 | [diff] [blame] | 57 | } |