config_host/config_global.h.in                     |    1 
 configure.ac                                       |   17 +++++++++
 dbaccess/source/ui/dlg/DbAdminImpl.cxx             |   36 +++++++++------------
 dbaccess/source/ui/querydesign/QueryDesignView.cxx |    2 -
 extensions/source/dbpilots/gridwizard.cxx          |    2 -
 fpicker/source/office/commonpicker.cxx             |   16 ++++-----
 include/rtl/string.hxx                             |   14 ++++++++
 include/rtl/ustring.hxx                            |   25 ++++++++++++++
 sal/qa/rtl/strings/test_oustring_concat.cxx        |   10 ++++-
 svtools/source/dialogs/addresstemplate.cxx         |   10 ++---
 svx/source/form/fmsrccfg.cxx                       |    8 +---
 toolkit/source/controls/formattedcontrol.cxx       |    6 +--
 12 files changed, 100 insertions(+), 47 deletions(-)

New commits:
commit 9d3cb71115cfb34adde975f66f394303982f85be
Author: Stephan Bergmann <sberg...@redhat.com>
Date:   Mon Nov 9 12:22:17 2015 +0100

    Prevent += called on temporary O[U]String instances
    
    ...found regression e31205f3ec1f941ab5a188bfde6329edf2acc55b
    "EditUndoRemoveChars::GetStr must return a reference" and dubious code
    0e23f7b0839df68d277186b4df54ba391ac3406a "Lets assume this doesn't want to
    update m_pForcedPrefix->GetText() anyway" in addition to the apparent 
sillies
    directly fixed in this commit.
    
    Introduces HAVE_CXX11_REF_QUALIFIER.
    
    Change-Id: I564e98254fd53c1dd9b34193d7057c59721ee24c

diff --git a/config_host/config_global.h.in b/config_host/config_global.h.in
index 72e3f3c..c7c5987 100644
--- a/config_host/config_global.h.in
+++ b/config_host/config_global.h.in
@@ -14,6 +14,7 @@ Any change in this header will cause a rebuild of almost 
everything.
 
 #define HAVE_CXX11_CONSTEXPR 0
 #define HAVE_CXX14_CONSTEXPR 0
+#define HAVE_CXX11_REF_QUALIFIER 0
 #define HAVE_CXX14_SIZED_DEALLOCATION 0
 #define HAVE_GCC_BUILTIN_ATOMIC 0
 /* _Pragma */
diff --git a/configure.ac b/configure.ac
index cf52e9d..2f064eb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6335,6 +6335,23 @@ if test "$cxx14_constexpr" = yes; then
     AC_DEFINE([HAVE_CXX14_CONSTEXPR])
 fi
 
+AC_MSG_CHECKING([whether $CXX supports C++11 ref-qualifier])
+save_CXXFLAGS=$CXXFLAGS
+CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
+AC_LANG_PUSH([C++])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+    struct S {
+        void f() &;
+        void f() &&;
+    };
+    ]])], [cxx11_ref_qualifier=yes], [cxx11_ref_qualifier=no])
+AC_LANG_POP([C++])
+CXXFLAGS=$save_CXXFLAGS
+AC_MSG_RESULT([$cxx11_ref_qualifier])
+if test "$cxx11_ref_qualifier" = yes; then
+    AC_DEFINE([HAVE_CXX11_REF_QUALIFIER])
+fi
+
 AC_MSG_CHECKING([whether $CXX supports C++14 sized deallocation])
 if test "$CROSS_COMPILING" = TRUE; then
     cxx14_sized_deallocation=no
diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.cxx 
b/dbaccess/source/ui/dlg/DbAdminImpl.cxx
index 8455001..2ec9b1b 100644
--- a/dbaccess/source/ui/dlg/DbAdminImpl.cxx
+++ b/dbaccess/source/ui/dlg/DbAdminImpl.cxx
@@ -917,11 +917,10 @@ void 
ODbDataSourceAdministrationHelper::implTranslateProperty( SfxItemSet& _rSet
             }
             else {
                 OSL_FAIL(
-                    (   OString( 
"ODbDataSourceAdministrationHelper::implTranslateProperty: invalid property 
value (" )
-                    +=  OString( translatePropertyId( _nId ) )
-                    +=  OString( " should be no string)!" )
-                    ).getStr()
-                );
+                    OString(
+                        
"ODbDataSourceAdministrationHelper::implTranslateProperty: invalid property 
value ("
+                        + translatePropertyId(_nId)
+                        + " should be no string)!").getStr());
             }
             break;
 
@@ -947,11 +946,10 @@ void 
ODbDataSourceAdministrationHelper::implTranslateProperty( SfxItemSet& _rSet
             }
             else {
                 OSL_FAIL(
-                    (   OString( 
"ODbDataSourceAdministrationHelper::implTranslateProperty: invalid property 
value (" )
-                    +=  OString( translatePropertyId( _nId ) )
-                    +=  OString( " should be no boolean)!" )
-                    ).getStr()
-                );
+                    OString(
+                        
"ODbDataSourceAdministrationHelper::implTranslateProperty: invalid property 
value ("
+                        + translatePropertyId(_nId)
+                        + " should be no boolean)!").getStr());
             }
             break;
 
@@ -964,11 +962,10 @@ void 
ODbDataSourceAdministrationHelper::implTranslateProperty( SfxItemSet& _rSet
             }
             else {
                 OSL_FAIL(
-                    (   OString( 
"ODbDataSourceAdministrationHelper::implTranslateProperty: invalid property 
value (" )
-                    +=  OString( translatePropertyId( _nId ) )
-                    +=  OString( " should be no int)!" )
-                    ).getStr()
-                );
+                    OString(
+                        
"ODbDataSourceAdministrationHelper::implTranslateProperty: invalid property 
value ("
+                        + translatePropertyId(_nId)
+                        + " should be no int)!").getStr());
             }
             break;
 
@@ -997,11 +994,10 @@ void 
ODbDataSourceAdministrationHelper::implTranslateProperty( SfxItemSet& _rSet
             }
             else {
                 OSL_FAIL(
-                    (   OString( 
"ODbDataSourceAdministrationHelper::implTranslateProperty: invalid property 
value (" )
-                    +=  OString( translatePropertyId( _nId ) )
-                    +=  OString( " should be no string sequence)!" )
-                    ).getStr()
-                );
+                    OString(
+                        
"ODbDataSourceAdministrationHelper::implTranslateProperty: invalid property 
value ("
+                        + translatePropertyId(_nId)
+                        + " should be no string sequence)!").getStr());
             }
             break;
 
diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx 
b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
index 9312308..6d1907a 100644
--- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx
+++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
@@ -2758,7 +2758,7 @@ void OQueryDesignView::fillValidFields(const OUString& 
sAliasName, ComboBox* pFi
             for(;aStrIter != aStrEnd;++aStrIter)
             {
                 if (bAllTables || aStrIter->toChar() == '*')
-                    pFieldList->InsertEntry(OUString(strCurrentPrefix) += 
*aStrIter);
+                    pFieldList->InsertEntry(strCurrentPrefix + *aStrIter);
                 else
                     pFieldList->InsertEntry(*aStrIter);
             }
diff --git a/extensions/source/dbpilots/gridwizard.cxx 
b/extensions/source/dbpilots/gridwizard.cxx
index d79c06c..91b0d21b 100644
--- a/extensions/source/dbpilots/gridwizard.cxx
+++ b/extensions/source/dbpilots/gridwizard.cxx
@@ -203,7 +203,7 @@ namespace dbp
                     // the data field the column should be bound to
                     xColumn->setPropertyValue(s_sDataFieldProperty, 
makeAny(*pFormFieldName));
                     // the label
-                    xColumn->setPropertyValue(s_sLabelProperty, 
makeAny(OUString(*pFormFieldName) += *pColumnLabelPostfix));
+                    xColumn->setPropertyValue(s_sLabelProperty, 
makeAny(*pFormFieldName + *pColumnLabelPostfix));
                     // the width (<void/> => column will be auto-sized)
                     xColumn->setPropertyValue(s_sWidthProperty, Any());
 
diff --git a/fpicker/source/office/commonpicker.cxx 
b/fpicker/source/office/commonpicker.cxx
index 9546ab7..1e84b11 100644
--- a/fpicker/source/office/commonpicker.cxx
+++ b/fpicker/source/office/commonpicker.cxx
@@ -450,21 +450,19 @@ namespace svt
             else
             {
                 OSL_FAIL(
-                    (   OString( "OCommonPicker::initialize: unknown argument 
type at position " )
-                    +=  OString::number( pArguments - 
_rArguments.getConstArray() )
-                    ).getStr()
-                );
+                    OString(
+                        "OCommonPicker::initialize: unknown argument type at 
position "
+                        + OString::number(pArguments - 
_rArguments.getConstArray())).getStr());
                 continue;
             }
 
             bool bKnownSetting =
                 implHandleInitializationArgument( sSettingName, aSettingValue 
);
             DBG_ASSERT( bKnownSetting,
-                (   OString( "OCommonPicker::initialize: unknown argument \"" )
-                +=  OString( sSettingName.getStr(), sSettingName.getLength(), 
osl_getThreadTextEncoding() )
-                +=  OString( "\"!" )
-                ).getStr()
-            );
+                OString(
+                    "OCommonPicker::initialize: unknown argument \""
+                    + OString(sSettingName.getStr(), sSettingName.getLength(), 
osl_getThreadTextEncoding())
+                    + "\"!").getStr() );
         }
     }
 
diff --git a/include/rtl/string.hxx b/include/rtl/string.hxx
index 2caafc2..ad143f5 100644
--- a/include/rtl/string.hxx
+++ b/include/rtl/string.hxx
@@ -33,6 +33,7 @@
 #include <rtl/stringutils.hxx>
 
 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
+#include <config_global.h>
 #include <rtl/stringconcat.hxx>
 #endif
 
@@ -309,10 +310,16 @@ public:
       @param    str         a OString.
     */
     OString & operator+=( const OString & str )
+#if defined LIBO_INTERNAL_ONLY && HAVE_CXX11_REF_QUALIFIER
+        &
+#endif
     {
         rtl_string_newConcat( &pData, pData, str.pData );
         return *this;
     }
+#if defined LIBO_INTERNAL_ONLY && HAVE_CXX11_REF_QUALIFIER
+    void operator+=(OString const &) && = delete;
+#endif
 
 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
     /**
@@ -321,6 +328,9 @@ public:
     */
     template< typename T1, typename T2 >
     OString& operator+=( const OStringConcat< T1, T2 >& c )
+#if HAVE_CXX11_REF_QUALIFIER
+        &
+#endif
     {
         sal_Int32 l = c.length();
         if( l == 0 )
@@ -332,6 +342,10 @@ public:
         pData->length = l;
         return *this;
     }
+#if HAVE_CXX11_REF_QUALIFIER
+    template<typename T1, typename T2> void operator +=(
+        OStringConcat<T1, T2> const &) && = delete;
+#endif
 #endif
 
     /**
diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx
index ee96da1..398dd93 100644
--- a/include/rtl/ustring.hxx
+++ b/include/rtl/ustring.hxx
@@ -34,6 +34,7 @@
 #include <sal/log.hxx>
 
 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
+#include <config_global.h>
 #include <rtl/stringconcat.hxx>
 #endif
 
@@ -419,10 +420,16 @@ public:
       @param    str         a OUString.
     */
     OUString & operator+=( const OUString & str )
+#if defined LIBO_INTERNAL_ONLY && HAVE_CXX11_REF_QUALIFIER
+        &
+#endif
     {
         rtl_uString_newConcat( &pData, pData, str.pData );
         return *this;
     }
+#if defined LIBO_INTERNAL_ONLY && HAVE_CXX11_REF_QUALIFIER
+    void operator+=(OUString const &) && = delete;
+#endif
 
     /** Append an ASCII string literal to this string.
 
@@ -432,7 +439,11 @@ public:
     */
     template<typename T>
     typename libreoffice_internal::ConstCharArrayDetector<T, OUString &>::Type
-    operator +=(T & literal) {
+    operator +=(T & literal)
+#if defined LIBO_INTERNAL_ONLY && HAVE_CXX11_REF_QUALIFIER
+        &
+#endif
+    {
         assert(
             libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
         rtl_uString_newConcatAsciiL(
@@ -441,6 +452,11 @@ public:
             libreoffice_internal::ConstCharArrayDetector<T>::length);
         return *this;
     }
+#if defined LIBO_INTERNAL_ONLY && HAVE_CXX11_REF_QUALIFIER
+    template<typename T>
+    typename libreoffice_internal::ConstCharArrayDetector<T, OUString &>::Type
+    operator +=(T &) && = delete;
+#endif
 
 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
     /**
@@ -449,6 +465,9 @@ public:
     */
     template< typename T1, typename T2 >
     OUString& operator+=( const OUStringConcat< T1, T2 >& c )
+#if HAVE_CXX11_REF_QUALIFIER
+        &
+#endif
     {
         sal_Int32 l = c.length();
         if( l == 0 )
@@ -460,6 +479,10 @@ public:
         pData->length = l;
         return *this;
     }
+#if HAVE_CXX11_REF_QUALIFIER
+    template<typename T1, typename T2> void operator +=(
+        OUStringConcat<T1, T2> const &) && = delete;
+#endif
 #endif
 
     /**
diff --git a/sal/qa/rtl/strings/test_oustring_concat.cxx 
b/sal/qa/rtl/strings/test_oustring_concat.cxx
index 9772296..3bc69e1 100644
--- a/sal/qa/rtl/strings/test_oustring_concat.cxx
+++ b/sal/qa/rtl/strings/test_oustring_concat.cxx
@@ -75,8 +75,14 @@ void test::oustring::StringConcat::checkConcat()
 
 void test::oustring::StringConcat::checkConcatAsciiL()
 {
-    CPPUNIT_ASSERT_EQUAL(OUString("foo"), OUString("foo") += "");
-    CPPUNIT_ASSERT_EQUAL(OUString("foobar"), OUString("foo") += "bar");
+    {
+        OUString s("foo");
+        CPPUNIT_ASSERT_EQUAL(OUString("foo"), s += "");
+    }
+    {
+        OUString s("foo");
+        CPPUNIT_ASSERT_EQUAL(OUString("foobar"), s += "bar");
+    }
 }
 
 void test::oustring::StringConcat::checkEnsureCapacity()
diff --git a/svtools/source/dialogs/addresstemplate.cxx 
b/svtools/source/dialogs/addresstemplate.cxx
index 9c6da2d..1f19223 100644
--- a/svtools/source/dialogs/addresstemplate.cxx
+++ b/svtools/source/dialogs/addresstemplate.cxx
@@ -183,11 +183,11 @@ public:
             }
             else
             {
-                OSL_FAIL(   (   
OString("AssigmentTransientData::AssigmentTransientData: unknown programmatic 
name (")
-                                +=  
OString(pFields->ProgrammaticName.getStr(), 
pFields->ProgrammaticName.getLength(), RTL_TEXTENCODING_ASCII_US)
-                                +=  OString(")!")
-                                ).getStr()
-                            );
+                OSL_FAIL(
+                    OString(
+                        "AssigmentTransientData::AssigmentTransientData: 
unknown programmatic name ("
+                        + OString(pFields->ProgrammaticName.getStr(), 
pFields->ProgrammaticName.getLength(), RTL_TEXTENCODING_ASCII_US)
+                        + ")!").getStr());
             }
         }
     }
diff --git a/svx/source/form/fmsrccfg.cxx b/svx/source/form/fmsrccfg.cxx
index f644f2d..ca58fe6 100644
--- a/svx/source/form/fmsrccfg.cxx
+++ b/svx/source/form/fmsrccfg.cxx
@@ -135,11 +135,9 @@ namespace svxform
         }
 
         OSL_FAIL(
-            (   OString( "lcl_implMapIntValue: could not convert the integer 
value " )
-            +=  OString::number( _nValue )
-            +=  OString( " !" )
-            ).getStr()
-        );
+            OString(
+                "lcl_implMapIntValue: could not convert the integer value "
+                + OString::number(_nValue) + " !").getStr());
         static const sal_Char* s_pDummy = "";
             // just as a fallback ....
         return s_pDummy;
diff --git a/toolkit/source/controls/formattedcontrol.cxx 
b/toolkit/source/controls/formattedcontrol.cxx
index ef8393b..5cd650d 100644
--- a/toolkit/source/controls/formattedcontrol.cxx
+++ b/toolkit/source/controls/formattedcontrol.cxx
@@ -363,9 +363,9 @@ namespace toolkit
             }
 
             throw IllegalArgumentException(
-                        ( OUString("Unable to convert the given value for the 
property ")
-                    +=  GetPropertyName((sal_uInt16)nPropId) )
-                    += " (double, integer, or string expected).",
+                ("Unable to convert the given value for the property "
+                 + GetPropertyName((sal_uInt16)nPropId)
+                 + " (double, integer, or string expected)."),
                 static_cast< XPropertySet* >(this),
                 1);
         }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to