From 2fe90a61bdf16bb1a08817ba544e2309b524a052 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 30 Jun 2014 14:34:39 -0700 Subject: Mark all QChar static functions as [[gnu::const]] The GCC documentation says that a const function is not allowed to read global memory. This needs to be clarified: it's not allowed to read RW global memory. It's fine to read read-only memory, as that is equivalent to just pure code. The QChar static out-of-line functions only lookup a property of the given Unicode character and always return the same value. The only exception is the decomposition() function, which returns a QString and is therefore not allowed to be marked const. Change-Id: Id36b2f84a1b8ff9db5acf1d4e59e8b3811068cff Reviewed-by: Konstantin Ritt Reviewed-by: Giuseppe D'Angelo --- src/corelib/tools/qchar.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/corelib/tools/qchar.cpp') diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp index eb59cc719f..656e57391f 100644 --- a/src/corelib/tools/qchar.cpp +++ b/src/corelib/tools/qchar.cpp @@ -1398,7 +1398,7 @@ QChar::UnicodeVersion QChar::currentUnicodeVersion() template -static inline T toLowerCase_helper(T uc) +Q_DECL_CONST_FUNCTION static inline T toLowerCase_helper(T uc) { const QUnicodeTables::Properties *p = qGetProp(uc); if (p->lowerCaseSpecial) { @@ -1409,7 +1409,7 @@ static inline T toLowerCase_helper(T uc) } template -static inline T toUpperCase_helper(T uc) +Q_DECL_CONST_FUNCTION static inline T toUpperCase_helper(T uc) { const QUnicodeTables::Properties *p = qGetProp(uc); if (p->upperCaseSpecial) { @@ -1420,7 +1420,7 @@ static inline T toUpperCase_helper(T uc) } template -static inline T toTitleCase_helper(T uc) +Q_DECL_CONST_FUNCTION static inline T toTitleCase_helper(T uc) { const QUnicodeTables::Properties *p = qGetProp(uc); if (p->titleCaseSpecial) { @@ -1431,7 +1431,7 @@ static inline T toTitleCase_helper(T uc) } template -static inline T toCaseFolded_helper(T uc) +Q_DECL_CONST_FUNCTION static inline T toCaseFolded_helper(T uc) { const QUnicodeTables::Properties *p = qGetProp(uc); if (p->caseFoldSpecial) { -- cgit v1.2.3