Ensure that qCleanupFuncinfo works with some C++11 new constructs

This commit adds tests for ref-qualified member functions, the new
syntax for functions and decltype.

__PRETTY_FUNCTION__ for lambdas varies wildly between compilers and will
produce really bizarre results after cleanup. It's not tested and is
known to be broken.

Change-Id: I70c8dbcba54790357cecba35aa45c5cc672f29d1
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
Thiago Macieira 2014-08-01 16:10:40 -07:00
parent 65ade55c8c
commit e319196f76
2 changed files with 37 additions and 0 deletions

View File

@ -1,5 +1,6 @@
CONFIG += testcase parallel_test
CONFIG -= app_bundle debug_and_release_target
contains(QT_CONFIG, c++11): CONFIG += c++11 c++14
TARGET = ../tst_qlogging
QT = core testlib
SOURCES = ../tst_qlogging.cpp

View File

@ -242,6 +242,26 @@ public:
int &operator--() { ADD("TestClass1::operator--"); return x; }
int operator--(int) { ADD("TestClass1::operator--"); return 0; }
#ifdef Q_COMPILER_REF_QUALIFIERS
int lvalue() & { ADD("TestClass1::lvalue"); return 0; }
int const_lvalue() const & { ADD("TestClass1::const_lvalue"); return 0; }
int rvalue() && { ADD("TestClass1::rvalue"); return 0; }
int const_rvalue() const && { ADD("TestClass1::const_rvalue"); return 0; }
#endif
#ifdef Q_COMPILER_DECLTYPE
int decltype_param(int x = 0, decltype(x) = 0) { ADD("TestClass1::decltype_param"); return x; }
template<typename T> int decltype_template_param(T x = 0, decltype(x) = 0)
{ ADD("TestClass1::decltype_template_param"); return x; }
template<typename T> void decltype_template_param2(T x, decltype(x + QString()))
{ ADD("TestClass1::decltype_template_param2"); }
# ifdef Q_COMPILER_AUTO_FUNCTION
auto decltype_return(int x = 0) -> decltype(x)
{ ADD("TestClass1::decltype_return"); return x; }
template <typename T> auto decltype_template_return(T x = 0) -> decltype(x)
{ ADD("TestClass1::decltype_template_return"); return x; }
# endif
#endif
public:
TestClass1()
{
@ -287,6 +307,22 @@ public:
operator++(0);
operator--();
operator--(0);
#ifdef Q_COMPILER_REF_QUALIFIERS
lvalue();
const_lvalue();
std::move(*this).rvalue();
std::move(*this).const_rvalue();
#endif
#ifdef Q_COMPILER_DECLTYPE
decltype_param();
decltype_template_param(0);
decltype_template_param2(QByteArray(), QString());
# ifdef Q_COMPILER_AUTO_FUNCTION
decltype_return();
decltype_template_return(0);
# endif
#endif
}
};