qt5base-lts/tests/auto/corelib/plugin
Martin Storsjö 70df6052d8 tst_QPluginLoader: Simplify creating a fake pointer in fakeplugin.cpp
When assigning multiple variables to a specific section, both GCC
and Clang legitimately error out if those variables wouldn't end
up in the same section (e.g. if one of them is going to a read-only
section while the other one is going to a read-write section).

In C++, when a seemingly const variable needs dynamic initialization,
it needs to be stored in a read-write section.

Clang 13 changed internals for how some constants are materialized.
Now, when a variable is initialized with an expression containing
plain old fashioned casts, it is considered to be potentially
runtime initialized (at the point when section assignment conflicts
is evaluated). Therefore, Clang 13 errors out on fakeplugin.cpp
with errors like:

    fakeplugin.cpp:36:39: error: 'message' causes a section type conflict with 'pluginSection'
    QT_PLUGIN_METADATA_SECTION const char message[] = "QTMETADATA";
                                          ^
    fakeplugin.cpp:32:40: note: declared here
    QT_PLUGIN_METADATA_SECTION void *const pluginSection = (void*)(0xc0ffeec0ffeeL);
                                           ^

See https://bugs.llvm.org/show_bug.cgi?id=51442 for discussion
on the matter in Clang.

To simplify things, just initialize the fake pointers as regular
uintptr_t instead, avoiding the whole matter. This produces the
exact same contents in the section as before.

For what it's worth, the actual manually constructed metadata in
fakeplugin.cpp doesn't seem to have any effect on running the
QPluginLoader tests on either ELF or MachO right now.

Change-Id: Ib84a2ceb20cb8e3a1bb5132a5715538e08049616
Pick-to: 6.2 6.1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-20 22:19:58 +03:00
..
qfactoryloader Fix BASE argument of qt_add_resources 2021-05-18 16:02:52 +02:00
qlibrary Fix BASE argument of qt_add_resources 2021-05-18 16:02:52 +02:00
qplugin Blacklist and skip failing tests on macOS ARM 2021-05-04 22:58:59 +02:00
qpluginloader tst_QPluginLoader: Simplify creating a fake pointer in fakeplugin.cpp 2021-08-20 22:19:58 +03:00
quuid QUuid: port to QAnyStringView 2021-07-30 22:54:28 +02:00
CMakeLists.txt Android: blacklist a list of failing tests for android 2020-11-04 12:27:49 +02:00