Browse Source

doc: suppress useless "this pointer is null" warnings on GCC 11+.

Having code snippets in docs compiled and checked for syntax and
outdated API errors is great. In theory. In practice the people reading
docs have NO IDEA how much needless suffering goes into making the
compiler collaborate with me on such a seemingly simple task. UGH.
pull/601/head
Vladimír Vondruš 3 years ago
parent
commit
8f97068be8
  1. 18
      doc/snippets/MagnumShaderTools.cpp
  2. 38
      doc/snippets/MagnumText.cpp
  3. 24
      doc/snippets/MagnumTrade.cpp

18
doc/snippets/MagnumShaderTools.cpp

@ -100,7 +100,11 @@ Containers::Optional<Containers::Array<char>> spirv =
} }
{ {
Containers::Pointer<ShaderTools::AbstractConverter> converter; /* -Wnonnull in GCC 11+ "helpfully" says "this is null" if I don't initialize
the converter pointer. I don't care, I just want you to check compilation
errors, not more! */
PluginManager::Manager<ShaderTools::AbstractConverter> manager;
Containers::Pointer<ShaderTools::AbstractConverter> converter = manager.loadAndInstantiate("SomethingWhatever");
Containers::Array<char> extract(const std::string&, const std::string&); Containers::Array<char> extract(const std::string&, const std::string&);
/* [AbstractConverter-usage-callbacks] */ /* [AbstractConverter-usage-callbacks] */
struct Data { struct Data {
@ -136,7 +140,11 @@ auto result = converter->validateFile(ShaderTools::Stage::Fragment, "ssao.frag")
} }
{ {
Containers::Pointer<ShaderTools::AbstractConverter> converter; /* -Wnonnull in GCC 11+ "helpfully" says "this is null" if I don't initialize
the converter pointer. I don't care, I just want you to check compilation
errors, not more! */
PluginManager::Manager<ShaderTools::AbstractConverter> manager;
Containers::Pointer<ShaderTools::AbstractConverter> converter = manager.loadAndInstantiate("SomethingWhatever");
/* [AbstractConverter-setInputFileCallback] */ /* [AbstractConverter-setInputFileCallback] */
converter->setInputFileCallback([](const std::string& filename, converter->setInputFileCallback([](const std::string& filename,
InputFileCallbackPolicy, void*) { InputFileCallbackPolicy, void*) {
@ -147,7 +155,11 @@ converter->setInputFileCallback([](const std::string& filename,
} }
{ {
Containers::Pointer<ShaderTools::AbstractConverter> converter; /* -Wnonnull in GCC 11+ "helpfully" says "this is null" if I don't initialize
the converter pointer. I don't care, I just want you to check compilation
errors, not more! */
PluginManager::Manager<ShaderTools::AbstractConverter> manager;
Containers::Pointer<ShaderTools::AbstractConverter> converter = manager.loadAndInstantiate("SomethingWhatever");
/* [AbstractConverter-setInputFileCallback-template] */ /* [AbstractConverter-setInputFileCallback-template] */
const Utility::Resource rs{"data"}; const Utility::Resource rs{"data"};
converter->setInputFileCallback([](const std::string& filename, converter->setInputFileCallback([](const std::string& filename,

38
doc/snippets/MagnumText.cpp

@ -39,6 +39,8 @@
#include "Magnum/Text/DistanceFieldGlyphCache.h" #include "Magnum/Text/DistanceFieldGlyphCache.h"
#include "Magnum/Text/Renderer.h" #include "Magnum/Text/Renderer.h"
#define DOXYGEN_ELLIPSIS(...) __VA_ARGS__
using namespace Magnum; using namespace Magnum;
using namespace Magnum::Math::Literals; using namespace Magnum::Math::Literals;
@ -61,7 +63,11 @@ font->fillGlyphCache(cache, "abcdefghijklmnopqrstuvwxyz"
#if defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) #if defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT))
{ {
Containers::Pointer<Text::AbstractFont> font; /* -Wnonnull in GCC 11+ "helpfully" says "this is null" if I don't initialize
the font pointer. I don't care, I just want you to check compilation errors,
not more! */
PluginManager::Manager<Text::AbstractFont> manager;
Containers::Pointer<Text::AbstractFont> font = manager.loadAndInstantiate("SomethingWhatever");
/* [AbstractFont-usage-callbacks] */ /* [AbstractFont-usage-callbacks] */
struct Data { struct Data {
std::unordered_map<std::string, Containers::Optional< std::unordered_map<std::string, Containers::Optional<
@ -95,7 +101,11 @@ font->openFile("magnum-font.conf", 13.0f);
#endif #endif
{ {
Containers::Pointer<Text::AbstractFont> font; /* -Wnonnull in GCC 11+ "helpfully" says "this is null" if I don't initialize
the font pointer. I don't care, I just want you to check compilation errors,
not more! */
PluginManager::Manager<Text::AbstractFont> manager;
Containers::Pointer<Text::AbstractFont> font = manager.loadAndInstantiate("SomethingWhatever");
/* [AbstractFont-setFileCallback] */ /* [AbstractFont-setFileCallback] */
font->setFileCallback([](const std::string& filename, font->setFileCallback([](const std::string& filename,
InputFileCallbackPolicy, void*) { InputFileCallbackPolicy, void*) {
@ -106,7 +116,11 @@ font->setFileCallback([](const std::string& filename,
} }
{ {
Containers::Pointer<Text::AbstractFont> font; /* -Wnonnull in GCC 11+ "helpfully" says "this is null" if I don't initialize
the font pointer. I don't care, I just want you to check compilation errors,
not more! */
PluginManager::Manager<Text::AbstractFont> manager;
Containers::Pointer<Text::AbstractFont> font = manager.loadAndInstantiate("SomethingWhatever");
/* [AbstractFont-setFileCallback-template] */ /* [AbstractFont-setFileCallback-template] */
const Utility::Resource rs{"data"}; const Utility::Resource rs{"data"};
font->setFileCallback([](const std::string& filename, font->setFileCallback([](const std::string& filename,
@ -117,8 +131,12 @@ font->setFileCallback([](const std::string& filename,
} }
{ {
/* -Wnonnull in GCC 11+ "helpfully" says "this is null" if I don't initialize
the font pointer. I don't care, I just want you to check compilation errors,
not more! */
PluginManager::Manager<Text::AbstractFont> manager;
/* [DistanceFieldGlyphCache-usage] */ /* [DistanceFieldGlyphCache-usage] */
Containers::Pointer<Text::AbstractFont> font; Containers::Pointer<Text::AbstractFont> font = DOXYGEN_ELLIPSIS(manager.loadAndInstantiate("SomethingWhatever"));
Text::DistanceFieldGlyphCache cache{Vector2i{2048}, Vector2i{384}, 16}; Text::DistanceFieldGlyphCache cache{Vector2i{2048}, Vector2i{384}, 16};
font->fillGlyphCache(cache, "abcdefghijklmnopqrstuvwxyz" font->fillGlyphCache(cache, "abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
@ -127,8 +145,12 @@ font->fillGlyphCache(cache, "abcdefghijklmnopqrstuvwxyz"
} }
{ {
/* -Wnonnull in GCC 11+ "helpfully" says "this is null" if I don't initialize
the font pointer. I don't care, I just want you to check compilation errors,
not more! */
PluginManager::Manager<Text::AbstractFont> manager;
/* [GlyphCache-usage] */ /* [GlyphCache-usage] */
Containers::Pointer<Text::AbstractFont> font; Containers::Pointer<Text::AbstractFont> font = DOXYGEN_ELLIPSIS(manager.loadAndInstantiate("SomethingWhatever"));
Text::GlyphCache cache{Vector2i{512}}; Text::GlyphCache cache{Vector2i{512}};
font->fillGlyphCache(cache, "abcdefghijklmnopqrstuvwxyz" font->fillGlyphCache(cache, "abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
@ -138,9 +160,13 @@ font->fillGlyphCache(cache, "abcdefghijklmnopqrstuvwxyz"
{ {
Matrix3 projectionMatrix; Matrix3 projectionMatrix;
/* -Wnonnull in GCC 11+ "helpfully" says "this is null" if I don't initialize
the font pointer. I don't care, I just want you to check compilation errors,
not more! */
PluginManager::Manager<Text::AbstractFont> manager;
/* [Renderer-usage1] */ /* [Renderer-usage1] */
/* Font instance, received from a plugin manager */ /* Font instance, received from a plugin manager */
Containers::Pointer<Text::AbstractFont> font; Containers::Pointer<Text::AbstractFont> font = DOXYGEN_ELLIPSIS(manager.loadAndInstantiate("SomethingWhatever"));
/* Configured glyph cache */ /* Configured glyph cache */
Text::GlyphCache cache{Vector2i{512}}; Text::GlyphCache cache{Vector2i{512}};

24
doc/snippets/MagnumTrade.cpp

@ -149,7 +149,11 @@ if(!image) Fatal{} << "Importing the image failed";
} }
{ {
Containers::Pointer<Trade::AbstractImporter> importer; /* -Wnonnull in GCC 11+ "helpfully" says "this is null" if I don't initialize
the converter pointer. I don't care, I just want you to check compilation
errors, not more! */
PluginManager::Manager<Trade::AbstractImporter> manager;
Containers::Pointer<Trade::AbstractImporter> importer = manager.loadAndInstantiate("SomethingWhatever");
/* [AbstractImporter-usage-data] */ /* [AbstractImporter-usage-data] */
Utility::Resource rs{"data"}; Utility::Resource rs{"data"};
Containers::ArrayView<const char> data = rs.getRaw("image.png"); Containers::ArrayView<const char> data = rs.getRaw("image.png");
@ -162,7 +166,11 @@ if(!importer->openData(data)) /* or openMemory() */
#if defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) #if defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT))
{ {
Containers::Pointer<Trade::AbstractImporter> importer; /* -Wnonnull in GCC 11+ "helpfully" says "this is null" if I don't initialize
the converter pointer. I don't care, I just want you to check compilation
errors, not more! */
PluginManager::Manager<Trade::AbstractImporter> manager;
Containers::Pointer<Trade::AbstractImporter> importer = manager.loadAndInstantiate("SomethingWhatever");
/* [AbstractImporter-usage-callbacks] */ /* [AbstractImporter-usage-callbacks] */
struct Data { struct Data {
std::unordered_map<std::string, Containers::Optional< std::unordered_map<std::string, Containers::Optional<
@ -196,7 +204,11 @@ importer->openFile("scene.gltf"); // memory-maps all files
#endif #endif
{ {
Containers::Pointer<Trade::AbstractImporter> importer; /* -Wnonnull in GCC 11+ "helpfully" says "this is null" if I don't initialize
the converter pointer. I don't care, I just want you to check compilation
errors, not more! */
PluginManager::Manager<Trade::AbstractImporter> manager;
Containers::Pointer<Trade::AbstractImporter> importer = manager.loadAndInstantiate("SomethingWhatever");
/* [AbstractImporter-setFileCallback] */ /* [AbstractImporter-setFileCallback] */
importer->setFileCallback([](const std::string& filename, importer->setFileCallback([](const std::string& filename,
InputFileCallbackPolicy, void*) { InputFileCallbackPolicy, void*) {
@ -207,7 +219,11 @@ importer->setFileCallback([](const std::string& filename,
} }
{ {
Containers::Pointer<Trade::AbstractImporter> importer; /* -Wnonnull in GCC 11+ "helpfully" says "this is null" if I don't initialize
the converter pointer. I don't care, I just want you to check compilation
errors, not more! */
PluginManager::Manager<Trade::AbstractImporter> manager;
Containers::Pointer<Trade::AbstractImporter> importer = manager.loadAndInstantiate("SomethingWhatever");
/* [AbstractImporter-setFileCallback-template] */ /* [AbstractImporter-setFileCallback-template] */
const Utility::Resource rs{"data"}; const Utility::Resource rs{"data"};
importer->setFileCallback([](const std::string& filename, importer->setFileCallback([](const std::string& filename,

Loading…
Cancel
Save