qt5base-lts/tests/auto/corelib/plugin/qpluginloader
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
..
almostplugin Remove .prev_CMakeLists.txt files 2021-01-12 20:59:13 +01:00
elftest Remove spurious execute permissions 2017-12-08 13:27:42 +00:00
lib Remove .prev_CMakeLists.txt files 2021-01-12 20:59:13 +01:00
machtest Remove the qmake project files 2021-01-07 15:32:28 +01:00
staticplugin Remove .prev_CMakeLists.txt files 2021-01-12 20:59:13 +01:00
theplugin Remove the qmake project files 2021-01-07 15:32:28 +01:00
tst Remove the qmake project files 2021-01-07 15:32:28 +01:00
.gitignore Moving relevant tests to corelib/plugin 2011-09-01 12:42:51 +02:00
BLACKLIST CMake: Fix failing tests on macOS developer builds 2020-09-22 19:08:53 +02:00
CMakeLists.txt cmake: Remove APPLE prefix from platform names 2020-03-16 17:57:56 +01:00
empty.json Use new plugin system in plugin autotest. 2012-02-23 16:38:45 +01:00
fakeplugin.cpp tst_QPluginLoader: Simplify creating a fake pointer in fakeplugin.cpp 2021-08-20 22:19:58 +03:00
tst_qpluginloader.cpp Replace QtTest headers with QTest 2020-12-22 15:20:30 +01:00
utf8_data.json moc: Fix compilation of text strings containing non-ASCII 2018-09-10 04:17:03 +00:00