mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK: Add a helper macro to temporarily ignore diagnostics with _Pragma()
This commit is contained in:
parent
6e4f886999
commit
d2e143eec7
Notes:
sideshowbarker
2024-07-17 09:48:50 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/d2e143eec7 Pull-request: https://github.com/SerenityOS/serenity/pull/16338 Reviewed-by: https://github.com/awesomekling ✅
1 changed files with 22 additions and 0 deletions
22
AK/Diagnostics.h
Normal file
22
AK/Diagnostics.h
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Needed to turn the 'name' token and the preceding 'GCC diagnostic ignored'
|
||||||
|
// into a single string literal, it won't accept "foo"#bar concatenation.
|
||||||
|
#define _AK_PRAGMA(x) _Pragma(#x)
|
||||||
|
#define AK_PRAGMA(x) _AK_PRAGMA(x)
|
||||||
|
|
||||||
|
// Helper macro to temporarily disable a diagnostic for the given statement.
|
||||||
|
// Using _Pragma() makes it possible to use this in other macros as well (and
|
||||||
|
// allows us to define it as a macro in the first place).
|
||||||
|
// NOTE: 'GCC' is also recognized by clang.
|
||||||
|
#define AK_IGNORE_DIAGNOSTIC(name, statement) \
|
||||||
|
AK_PRAGMA(GCC diagnostic push); \
|
||||||
|
AK_PRAGMA(GCC diagnostic ignored name); \
|
||||||
|
statement; \
|
||||||
|
AK_PRAGMA(GCC diagnostic pop);
|
Loading…
Reference in a new issue