Emit final macro diagnostics in system headers

Final macro diagnostics should log from system headers.

As planned, final macros are hard-mode. They always log diagnostics.
This commit is contained in:
Chris Bieneman 2021-11-11 13:50:49 -06:00
parent 75ecd1f38c
commit 3e7ad1f2b2
3 changed files with 11 additions and 2 deletions

View File

@ -564,7 +564,7 @@ def note_pp_macro_annotation :
def warn_pragma_final_macro :
ExtWarn<"macro %0 has been marked as final and should not be "
"%select{undefined|redefined}1">,
InGroup<FinalMacro>;
InGroup<FinalMacro>, ShowInSystemHeader;
// - #pragma execution_character_set(...)
def warn_pragma_exec_charset_expected :

View File

@ -0,0 +1,4 @@
// expected-warning@+1{{macro 'SYSTEM_MACRO' has been marked as final and should not be undefined}}
#undef SYSTEM_MACRO
// expected-warning@+1{{macro 'SYSTEM_MACRO' has been marked as final and should not be redefined}}
#define SYSTEM_MACRO WoahMoar

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -Wfinal-macro %s -fsyntax-only -verify
// RUN: %clang_cc1 -Wfinal-macro %s -fsyntax-only -isystem %S/Inputs -verify
// Test warning production
#define Foo 1
@ -43,3 +43,8 @@
// no diagnostics triggered by these pragmas.
#pragma clang deprecated(Foo)
#pragma clang restrict_expansion(Foo)
#define SYSTEM_MACRO Woah
// expected-note@+1 2{{macro marked 'final' here}}
#pragma clang final(SYSTEM_MACRO)
#include <final-macro-system.h>