| 1 |
/* Test path-printing in the face of macros. */ |
| 2 |
|
| 3 |
/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */ |
| 4 |
/* { dg-skip-if "requires hosted libstdc++ for stdlib free" { ! hostedlib } } */ |
| 5 |
/* { dg-enable-nn-line-numbers "" } */ |
| 6 |
|
| 7 |
#include "malloc-macro.h" |
| 8 |
|
| 9 |
/* { dg-warning "double-'free' of 'ptr'" "" { target *-*-* } 2 } */ |
| 10 |
|
| 11 |
void test (void *ptr) |
| 12 |
{ |
| 13 |
WRAPPED_FREE (ptr); /* { dg-message "in expansion of macro 'WRAPPED_FREE'" } */ |
| 14 |
WRAPPED_FREE (ptr); /* { dg-message "in expansion of macro 'WRAPPED_FREE'" } */ |
| 15 |
|
| 16 |
/* { dg-begin-multiline-output "" } |
| 17 |
NN | #define WRAPPED_FREE(PTR) free(PTR) |
| 18 |
| ^~~~~~~~~ |
| 19 |
NN | WRAPPED_FREE (ptr); |
| 20 |
| ^~~~~~~~~~~~ |
| 21 |
{ dg-end-multiline-output "" { target c } } */ |
| 22 |
/* { dg-begin-multiline-output "" } |
| 23 |
NN | #define WRAPPED_FREE(PTR) free(PTR) |
| 24 |
| ~~~~^~~~~ |
| 25 |
NN | WRAPPED_FREE (ptr); |
| 26 |
| ^~~~~~~~~~~~ |
| 27 |
{ dg-end-multiline-output "" { target c++ } } */ |
| 28 |
/* { dg-begin-multiline-output "" } |
| 29 |
'test': event 1 |
| 30 |
{ dg-end-multiline-output "" { target c } } */ |
| 31 |
/* { dg-begin-multiline-output "" } |
| 32 |
'void test(void*)': event 1 |
| 33 |
{ dg-end-multiline-output "" { target c++ } } */ |
| 34 |
/* { dg-prune-output "\[^\n\r\]*malloc-macro.h\[^\n\r\]*" } */ |
| 35 |
/* { dg-begin-multiline-output "" } |
| 36 |
NN | #define WRAPPED_FREE(PTR) free(PTR) |
| 37 |
| ^~~~~~~~~ |
| 38 |
| | |
| 39 |
| (1) first 'free' here |
| 40 |
NN | WRAPPED_FREE (ptr); |
| 41 |
| ^~~~~~~~~~~~ |
| 42 |
{ dg-end-multiline-output "" { target c } } */ |
| 43 |
/* { dg-begin-multiline-output "" } |
| 44 |
NN | #define WRAPPED_FREE(PTR) free(PTR) |
| 45 |
| ~~~~^~~~~ |
| 46 |
| | |
| 47 |
| (1) first 'free' here |
| 48 |
NN | WRAPPED_FREE (ptr); |
| 49 |
| ^~~~~~~~~~~~ |
| 50 |
{ dg-end-multiline-output "" { target c++ } } */ |
| 51 |
/* { dg-prune-output "\[^\n\r\]*malloc-macro.h\[^\n\r\]*" } */ |
| 52 |
/* { dg-begin-multiline-output "" } |
| 53 |
'test': event 2 |
| 54 |
{ dg-end-multiline-output "" { target c } } */ |
| 55 |
/* { dg-begin-multiline-output "" } |
| 56 |
'void test(void*)': event 2 |
| 57 |
{ dg-end-multiline-output "" { target c++ } } */ |
| 58 |
/* { dg-prune-output "\[^\n\r\]*malloc-macro.h\[^\n\r\]*" } */ |
| 59 |
/* { dg-begin-multiline-output "" } |
| 60 |
NN | #define WRAPPED_FREE(PTR) free(PTR) |
| 61 |
| ^~~~~~~~~ |
| 62 |
| | |
| 63 |
| (2) second 'free' here; first 'free' was at (1) |
| 64 |
NN | WRAPPED_FREE (ptr); |
| 65 |
| ^~~~~~~~~~~~ |
| 66 |
{ dg-end-multiline-output "" { target c } } */ |
| 67 |
/* { dg-begin-multiline-output "" } |
| 68 |
NN | #define WRAPPED_FREE(PTR) free(PTR) |
| 69 |
| ~~~~^~~~~ |
| 70 |
| | |
| 71 |
| (2) second 'free' here; first 'free' was at (1) |
| 72 |
NN | WRAPPED_FREE (ptr); |
| 73 |
| ^~~~~~~~~~~~ |
| 74 |
{ dg-end-multiline-output "" { target c++ } } */ |
| 75 |
} |