r358152 - Add { } to silence compiler warning [NFC]

Mikael Holmen via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 10 23:57:12 PDT 2019


Author: uabelho
Date: Wed Apr 10 23:57:12 2019
New Revision: 358152

URL: http://llvm.org/viewvc/llvm-project?rev=358152&view=rev
Log:
Add { } to silence compiler warning [NFC]

At least clang 3.6 warns on the original code:

../tools/clang/lib/CodeGen/CGNonTrivialStruct.cpp:829:34: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
  return std::array<Address, 1>({Address(nullptr, CharUnits::Zero())});
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                 {                                  }
../tools/clang/lib/CodeGen/CGNonTrivialStruct.cpp:833:34: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
  return std::array<Address, 2>({Address(nullptr, CharUnits::Zero()),
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.

Modified:
    cfe/trunk/lib/CodeGen/CGNonTrivialStruct.cpp

Modified: cfe/trunk/lib/CodeGen/CGNonTrivialStruct.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGNonTrivialStruct.cpp?rev=358152&r1=358151&r2=358152&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGNonTrivialStruct.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGNonTrivialStruct.cpp Wed Apr 10 23:57:12 2019
@@ -826,12 +826,12 @@ static void callSpecialFunction(G &&Gen,
 template <size_t N> std::array<Address, N> createNullAddressArray();
 
 template <> std::array<Address, 1> createNullAddressArray() {
-  return std::array<Address, 1>({Address(nullptr, CharUnits::Zero())});
+  return std::array<Address, 1>({{Address(nullptr, CharUnits::Zero())}});
 }
 
 template <> std::array<Address, 2> createNullAddressArray() {
-  return std::array<Address, 2>({Address(nullptr, CharUnits::Zero()),
-                                 Address(nullptr, CharUnits::Zero())});
+  return std::array<Address, 2>({{Address(nullptr, CharUnits::Zero()),
+                                  Address(nullptr, CharUnits::Zero())}});
 }
 
 template <class G, size_t N>




More information about the cfe-commits mailing list