| 1 |
// RUN: %clang_cc1 -Wdeprecated %s -fsyntax-only -verify |
| 2 |
|
| 3 |
// expected-error@+1{{expected (}} |
| 4 |
#pragma clang deprecated |
| 5 |
|
| 6 |
// expected-error@+1{{expected identifier}} |
| 7 |
#pragma clang deprecated(4 |
| 8 |
|
| 9 |
// expected-error@+1{{no macro named 'foo'}} |
| 10 |
#pragma clang deprecated(foo) |
| 11 |
|
| 12 |
#define bar 1 |
| 13 |
// expected-note@+1{{macro marked 'deprecated' here}} |
| 14 |
#pragma clang deprecated(bar, "bar is deprecated use 1") |
| 15 |
|
| 16 |
// expected-warning@+1{{macro 'bar' has been marked as deprecated: bar is deprecated use 1}} |
| 17 |
#if bar |
| 18 |
#endif |
| 19 |
|
| 20 |
#define foo 1 |
| 21 |
// expected-note@+8{{macro marked 'deprecated' here}} |
| 22 |
// expected-note@+7{{macro marked 'deprecated' here}} |
| 23 |
// expected-note@+6{{macro marked 'deprecated' here}} |
| 24 |
// expected-note@+5{{macro marked 'deprecated' here}} |
| 25 |
// expected-note@+4{{macro marked 'deprecated' here}} |
| 26 |
// expected-note@+3{{macro marked 'deprecated' here}} |
| 27 |
// expected-note@+2{{macro marked 'deprecated' here}} |
| 28 |
// expected-note@+1{{macro marked 'deprecated' here}} |
| 29 |
#pragma clang deprecated(foo) |
| 30 |
|
| 31 |
// expected-error@+1{{expected )}} |
| 32 |
#pragma clang deprecated(foo |
| 33 |
|
| 34 |
// expected-warning@+1{{macro 'foo' has been marked as deprecated}} |
| 35 |
#if foo |
| 36 |
#endif |
| 37 |
|
| 38 |
// expected-warning@+1{{macro 'foo' has been marked as deprecated}} |
| 39 |
#if defined(foo) |
| 40 |
#endif |
| 41 |
|
| 42 |
// expected-warning@+1{{macro 'foo' has been marked as deprecated}} |
| 43 |
#ifdef foo |
| 44 |
#endif |
| 45 |
|
| 46 |
// expected-warning@+1{{macro 'foo' has been marked as deprecated}} |
| 47 |
#ifndef foo |
| 48 |
#endif |
| 49 |
|
| 50 |
int main(int argc, char** argv) { |
| 51 |
// expected-error@+1{{no macro named 'main'}} |
| 52 |
#pragma clang deprecated(main) |
| 53 |
|
| 54 |
// expected-warning@+1{{macro 'foo' has been marked as deprecated}} |
| 55 |
return foo; |
| 56 |
} |
| 57 |
|
| 58 |
#define frobble 1 |
| 59 |
#pragma clang deprecated(frobble) |
| 60 |
|
| 61 |
// not-expected-warning@+1{{macro 'frobble' has been marked as deprecated}} |
| 62 |
#undef frobble // Expect no diagnostics here |
| 63 |
|
| 64 |
// not-expected-warning@+1{{macro 'frobble' has been marked as deprecated}} |
| 65 |
#define frobble 1 // How about here given that this was undefined? |
| 66 |
|
| 67 |
// not-expected-warning@+1{{macro 'frobble' has been marked as deprecated}} |
| 68 |
#if defined(frobble) |
| 69 |
#endif |
| 70 |
|
| 71 |
// Test that we diagnose on #elif. |
| 72 |
#if 0 |
| 73 |
#elif foo |
| 74 |
// expected-warning@-1{{macro 'foo' has been marked as deprecated}} |
| 75 |
#endif |
| 76 |
|
| 77 |
|
| 78 |
// Test that we diagnose on #elifdef. |
| 79 |
#ifdef baz |
| 80 |
#elifdef foo |
| 81 |
// expected-warning@-1{{macro 'foo' has been marked as deprecated}} |
| 82 |
// expected-warning@-2{{use of a '#elifdef' directive is a C23 extension}} |
| 83 |
#endif |
| 84 |
|
| 85 |
// Test that we diagnose on #elifndef. |
| 86 |
#ifdef baz |
| 87 |
#elifndef foo |
| 88 |
#endif |
| 89 |
// expected-warning@-2{{macro 'foo' has been marked as deprecated}} |
| 90 |
// expected-warning@-3{{use of a '#elifndef' directive is a C23 extension}} |
| 91 |
|
| 92 |
// FIXME: These cases are currently not handled because clang doesn't expand |
| 93 |
// conditions on skipped #elif* blocks. See the FIXME notes in |
| 94 |
// Preprocessor::SkipExcludedConditionalBlock. |
| 95 |
|
| 96 |
#ifdef frobble |
| 97 |
// not-expected-warning@+2{{macro 'foo' has been marked as deprecated}} |
| 98 |
// expected-warning@+1{{use of a '#elifndef' directive is a C23 extension}} |
| 99 |
#elifndef foo |
| 100 |
#endif |
| 101 |
|
| 102 |
#ifdef frobble |
| 103 |
// not-expected-warning@+2{{macro 'foo' has been marked as deprecated}} |
| 104 |
// expected-warning@+1{{use of a '#elifdef' directive is a C23 extension}} |
| 105 |
#elifdef foo |
| 106 |
#endif |
| 107 |
|
| 108 |
#if 1 |
| 109 |
// not-expected-warning@+1{{macro 'foo' has been marked as deprecated}} |
| 110 |
#elif foo |
| 111 |
#endif |