| 1 |
// RUN: %clang_cc1 -Wfinal-macro %s -fsyntax-only -isystem %S/Inputs -verify |
| 2 |
|
| 3 |
// Test warning production |
| 4 |
#define Foo 1 |
| 5 |
// expected-note@+1 4{{macro marked 'final' here}} |
| 6 |
#pragma clang final(Foo) |
| 7 |
|
| 8 |
// expected-warning@+2{{macro 'Foo' has been marked as final and should not be redefined}} |
| 9 |
// expected-note@+1{{previous definition is here}} |
| 10 |
#define Foo 1 |
| 11 |
|
| 12 |
// expected-warning@+2{{macro 'Foo' has been marked as final and should not be redefined}} |
| 13 |
// expected-warning@+1{{'Foo' macro redefined}} |
| 14 |
#define Foo 2 |
| 15 |
|
| 16 |
// expected-warning@+1{{redefining builtin macro}} |
| 17 |
#define __TIME__ 1 |
| 18 |
|
| 19 |
// expected-warning@+1{{undefining builtin macro}} |
| 20 |
#undef __TIMESTAMP__ |
| 21 |
|
| 22 |
// expected-warning@+1{{macro 'Foo' has been marked as final and should not be undefined}} |
| 23 |
#undef Foo |
| 24 |
// expected-warning@+1{{macro 'Foo' has been marked as final and should not be redefined}} |
| 25 |
#define Foo 3 |
| 26 |
|
| 27 |
// Test parse errors |
| 28 |
// expected-error@+1{{expected (}} |
| 29 |
#pragma clang final |
| 30 |
|
| 31 |
// expected-error@+1{{expected )}} |
| 32 |
#pragma clang final(Foo |
| 33 |
|
| 34 |
// expected-error@+1{{no macro named 'Baz'}} |
| 35 |
#pragma clang final(Baz) |
| 36 |
|
| 37 |
// expected-error@+1{{expected identifier}} |
| 38 |
#pragma clang final(4) |
| 39 |
|
| 40 |
// expected-error@+1{{expected (}} |
| 41 |
#pragma clang final Baz |
| 42 |
|
| 43 |
// no diagnostics triggered by these pragmas. |
| 44 |
#pragma clang deprecated(Foo) |
| 45 |
#pragma clang restrict_expansion(Foo) |
| 46 |
|
| 47 |
#define SYSTEM_MACRO Woah |
| 48 |
// expected-note@+1 2{{macro marked 'final' here}} |
| 49 |
#pragma clang final(SYSTEM_MACRO) |
| 50 |
#include <final-macro-system.h> |