<div dir="auto">What is the effect on that testcase? (Sorry, heading to vacation and can't easily check.)</div><div class="gmail_extra"><br><div class="gmail_quote">On 27 Mar 2017 6:33 am, "Daniel Jasper" <<a href="mailto:djasper@google.com">djasper@google.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Richard,<div><br></div><div>this seems to have an unwanted side-effect on -Wunused-value (test case attached). Could you take a look?</div><div><br></div><div>Cheers,</div><div>Daniel</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 24, 2017 at 2:14 AM, Richard Smith via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rsmith<br>
Date: Thu Mar 23 20:14:25 2017<br>
New Revision: 298676<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=298676&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=298676&view=rev</a><br>
Log:<br>
Fix handling of initialization from parenthesized initializer list.<br>
<br>
This change fixes a crash on initialization of a reference from ({}) during<br>
template instantiation and incidentally improves diagnostics.<br>
<br>
This reverts a prior attempt to handle this in r286721. Instead, we teach the<br>
initialization code that initialization cannot be performed if a source type<br>
is required and the initializer is an initializer list (which is not an<br>
expression and does not have a type), and likewise for function-style cast<br>
expressions.<br>
<br>
Modified:<br>
    cfe/trunk/include/clang/Basic/<wbr>DiagnosticSemaKinds.td<br>
    cfe/trunk/include/clang/Sema/I<wbr>nitialization.h<br>
    cfe/trunk/include/clang/Sema/S<wbr>ema.h<br>
    cfe/trunk/lib/Sema/SemaDecl.cp<wbr>p<br>
    cfe/trunk/lib/Sema/SemaExprCXX<wbr>.cpp<br>
    cfe/trunk/lib/Sema/SemaInit.cp<wbr>p<br>
    cfe/trunk/test/SemaCXX/cxx0x-i<wbr>nitializer-constructor.cpp<br>
    cfe/trunk/test/SemaCXX/cxx0x-i<wbr>nitializer-references.cpp<br>
    cfe/trunk/test/SemaCXX/cxx0x-i<wbr>nitializer-scalars.cpp<br>
    cfe/trunk/test/SemaCXX/type-co<wbr>nvert-construct.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Basic/<wbr>DiagnosticSemaKinds.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=298676&r1=298675&r2=298676&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/include/clang/<wbr>Basic/DiagnosticSemaKinds.td?<wbr>rev=298676&r1=298675&r2=<wbr>298676&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/Basic/<wbr>DiagnosticSemaKinds.td (original)<br>
+++ cfe/trunk/include/clang/Basic/<wbr>DiagnosticSemaKinds.td Thu Mar 23 20:14:25 2017<br>
@@ -1814,8 +1814,9 @@ def note_uninit_fixit_remove_cond : Note<br>
   "remove the %select{'%1' if its condition|condition if it}0 "<br>
   "is always %select{false|true}2">;<br>
 def err_init_incomplete_type : Error<"initialization of incomplete type %0">;<br>
-def err_list_init_in_parens : Error<"list-initializer for non-class type %0 "<br>
-  "must not be parenthesized">;<br>
+def err_list_init_in_parens : Error<<br>
+  "cannot initialize %select{non-class|reference}0 type %1 with a "<br>
+  "parenthesized initializer list">;<br>
<br>
 def warn_unsequenced_mod_mod : Warning<<br>
   "multiple unsequenced modifications to %0">, InGroup<Unsequenced>;<br>
@@ -5865,8 +5866,8 @@ def err_builtin_func_cast_more_tha<wbr>n_one_<br>
   "function-style cast to a builtin type can only take one argument">;<br>
 def err_value_init_for_array_type : Error<<br>
   "array types cannot be value-initialized">;<br>
-def err_value_init_for_function_ty<wbr>pe : Error<<br>
-  "function types cannot be value-initialized">;<br>
+def err_init_for_function_type : Error<<br>
+  "cannot create object of function type %0">;<br>
 def warn_format_nonliteral_noargs : Warning<<br>
   "format string is not a string literal (potentially insecure)">,<br>
   InGroup<FormatSecurity>;<br>
<br>
Modified: cfe/trunk/include/clang/Sema/I<wbr>nitialization.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Initialization.h?rev=298676&r1=298675&r2=298676&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/include/clang/<wbr>Sema/Initialization.h?rev=<wbr>298676&r1=298675&r2=298676&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/Sema/I<wbr>nitialization.h (original)<br>
+++ cfe/trunk/include/clang/Sema/I<wbr>nitialization.h Thu Mar 23 20:14:25 2017<br>
@@ -822,6 +822,8 @@ public:<br>
   enum FailureKind {<br>
     /// \brief Too many initializers provided for a reference.<br>
     FK_TooManyInitsForReference,<br>
+    /// \brief Reference initialized from a parenthesized initializer list.<br>
+    FK_ParenthesizedListInitForRef<wbr>erence,<br>
     /// \brief Array must be initialized with an initializer list.<br>
     FK_ArrayNeedsInitList,<br>
     /// \brief Array must be initialized with an initializer list or a<br>
@@ -866,6 +868,8 @@ public:<br>
     FK_ConversionFromPropertyFail<wbr>ed,<br>
     /// \brief Too many initializers for scalar<br>
     FK_TooManyInitsForScalar,<br>
+    /// \brief Scalar initialized from a parenthesized initializer list.<br>
+    FK_ParenthesizedListInitForSca<wbr>lar,<br>
     /// \brief Reference initialization from an initializer list<br>
     FK_<wbr>ReferenceBindingToInitList,<br>
     /// \brief Initialization of some unused destination type with an<br>
@@ -892,7 +896,7 @@ public:<br>
     /// having its address taken.<br>
     FK_AddressOfUnaddressableFunc<wbr>tion,<br>
     /// \brief List-copy-initialization chose an explicit constructor.<br>
-    FK_ExplicitConstructor<br>
+    FK_ExplicitConstructor,<br>
   };<br>
<br>
 private:<br>
<br>
Modified: cfe/trunk/include/clang/Sema/S<wbr>ema.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=298676&r1=298675&r2=298676&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/include/clang/<wbr>Sema/Sema.h?rev=298676&r1=<wbr>298675&r2=298676&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/Sema/S<wbr>ema.h (original)<br>
+++ cfe/trunk/include/clang/Sema/S<wbr>ema.h Thu Mar 23 20:14:25 2017<br>
@@ -1822,7 +1822,6 @@ public:<br>
   void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit);<br>
   void ActOnUninitializedDecl(Decl *dcl);<br>
   void ActOnInitializerError(Decl *Dcl);<br>
-  bool canInitializeWithParenthesized<wbr>List(QualType TargetType);<br>
<br>
   void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc);<br>
   void ActOnCXXForRangeDecl(Decl *D);<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaDecl.cp<wbr>p<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=298676&r1=298675&r2=298676&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/Sema/SemaD<wbr>ecl.cpp?rev=298676&r1=298675&<wbr>r2=298676&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Sema/SemaDecl.cp<wbr>p (original)<br>
+++ cfe/trunk/lib/Sema/SemaDecl.cp<wbr>p Thu Mar 23 20:14:25 2017<br>
@@ -10102,18 +10102,6 @@ void Sema::AddInitializerToDecl(Dec<wbr>l *Re<br>
   // Perform the initialization.<br>
   ParenListExpr *CXXDirectInit = dyn_cast<ParenListExpr>(Init);<br>
   if (!VDecl->isInvalidDecl()) {<br>
-    // Handle errors like: int a({0})<br>
-    if (CXXDirectInit && CXXDirectInit->getNumExprs() == 1 &&<br>
-        !canInitializeWithParenthesize<wbr>dList(VDecl->getType()))<br>
-      if (auto IList = dyn_cast<InitListExpr>(CXXDire<wbr>ctInit->getExpr(0))) {<br>
-        Diag(VDecl->getLocation(), diag::err_list_init_in_parens)<br>
-            << VDecl->getType() << CXXDirectInit->getSourceRange(<wbr>)<br>
-            << FixItHint::CreateRemoval(CXXDi<wbr>rectInit->getLocStart())<br>
-            << FixItHint::CreateRemoval(CXXDi<wbr>rectInit->getLocEnd());<br>
-        Init = IList;<br>
-        CXXDirectInit = nullptr;<br>
-      }<br>
-<br>
     InitializedEntity Entity = InitializedEntity::InitializeV<wbr>ariable(VDecl);<br>
     InitializationKind Kind = InitializationKind::CreateForI<wbr>nit(<br>
         VDecl->getLocation(), DirectInit, Init);<br>
@@ -10413,18 +10401,6 @@ void Sema::ActOnInitializerError(De<wbr>cl *D<br>
   // though.<br>
 }<br>
<br>
-/// Checks if an object of the given type can be initialized with parenthesized<br>
-/// init-list.<br>
-///<br>
-/// \param TargetType Type of object being initialized.<br>
-///<br>
-/// The function is used to detect wrong initializations, such as 'int({0})'.<br>
-///<br>
-bool Sema::canInitializeWithParenth<wbr>esizedList(QualType TargetType) {<br>
-  return TargetType->isDependentType() || TargetType->isRecordType() ||<br>
-         TargetType->getContainedAutoT<wbr>ype();<br>
-}<br>
-<br>
 void Sema::ActOnUninitializedDecl(D<wbr>ecl *RealDecl) {<br>
   // If there is no declaration, there was an error parsing it. Just ignore it.<br>
   if (!RealDecl)<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaExprCXX<wbr>.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=298676&r1=298675&r2=298676&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/Sema/SemaE<wbr>xprCXX.cpp?rev=298676&r1=29867<wbr>5&r2=298676&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Sema/SemaExprCXX<wbr>.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaExprCXX<wbr>.cpp Thu Mar 23 20:14:25 2017<br>
@@ -1228,17 +1228,6 @@ Sema::ActOnCXXTypeConstructExp<wbr>r(ParsedTy<br>
   if (!TInfo)<br>
     TInfo = Context.getTrivialTypeSourceIn<wbr>fo(Ty, SourceLocation());<br>
<br>
-  // Handle errors like: int({0})<br>
-  if (exprs.size() == 1 && !canInitializeWithParenthesize<wbr>dList(Ty) &&<br>
-      LParenLoc.isValid() && RParenLoc.isValid())<br>
-    if (auto IList = dyn_cast<InitListExpr>(exprs[0<wbr>])) {<br>
-      Diag(TInfo->getTypeLoc().getLo<wbr>cStart(), diag::err_list_init_in_parens)<br>
-          << Ty << IList->getSourceRange()<br>
-          << FixItHint::CreateRemoval(LPare<wbr>nLoc)<br>
-          << FixItHint::CreateRemoval(RPare<wbr>nLoc);<br>
-      LParenLoc = RParenLoc = SourceLocation();<br>
-    }<br>
-<br>
   auto Result = BuildCXXTypeConstructExpr(TInf<wbr>o, LParenLoc, exprs, RParenLoc);<br>
   // Avoid creating a non-type-dependent expression that contains typos.<br>
   // Non-type-dependent expressions are liable to be discarded without<br>
@@ -1295,46 +1284,51 @@ Sema::BuildCXXTypeConstructExp<wbr>r(TypeSour<br>
   }<br>
<br>
   // C++ [expr.type.conv]p1:<br>
-  // If the expression list is a single expression, the type conversion<br>
-  // expression is equivalent (in definedness, and if defined in meaning) to the<br>
-  // corresponding cast expression.<br>
-  if (Exprs.size() == 1 && !ListInitialization) {<br>
+  // If the expression list is a parenthesized single expression, the type<br>
+  // conversion expression is equivalent (in definedness, and if defined in<br>
+  // meaning) to the corresponding cast expression.<br>
+  if (Exprs.size() == 1 && !ListInitialization &&<br>
+      !isa<InitListExpr>(Exprs[0])) {<br>
     Expr *Arg = Exprs[0];<br>
     return BuildCXXFunctionalCastExpr(TIn<wbr>fo, Ty, LParenLoc, Arg, RParenLoc);<br>
   }<br>
<br>
-  // C++14 [expr.type.conv]p2: The expression T(), where T is a<br>
-  //   simple-type-specifier or typename-specifier for a non-array complete<br>
-  //   object type or the (possibly cv-qualified) void type, creates a prvalue<br>
-  //   of the specified type, whose value is that produced by value-initializing<br>
-  //   an object of type T.<br>
+  //   For an expression of the form T(), T shall not be an array type.<br>
   QualType ElemTy = Ty;<br>
   if (Ty->isArrayType()) {<br>
     if (!ListInitialization)<br>
-      return ExprError(Diag(TyBeginLoc,<br>
-                            diag::err_value_init_for_array<wbr>_type) << FullRange);<br>
+      return ExprError(Diag(TyBeginLoc, diag::err_value_init_for_array<wbr>_type)<br>
+                         << FullRange);<br>
     ElemTy = Context.getBaseElementType(Ty)<wbr>;<br>
   }<br>
<br>
-  if (!ListInitialization && Ty->isFunctionType())<br>
-    return ExprError(Diag(TyBeginLoc, diag::err_value_init_for_funct<wbr>ion_type)<br>
-                     << FullRange);<br>
-<br>
+  // There doesn't seem to be an explicit rule against this but sanity demands<br>
+  // we only construct objects with object types.<br>
+  if (Ty->isFunctionType())<br>
+    return ExprError(Diag(TyBeginLoc, diag::err_init_for_function_ty<wbr>pe)<br>
+                       << Ty << FullRange);<br>
+<br>
+  // C++17 [expr.type.conv]p2:<br>
+  //   If the type is cv void and the initializer is (), the expression is a<br>
+  //   prvalue of the specified type that performs no initialization.<br>
   if (!Ty->isVoidType() &&<br>
       RequireCompleteType(TyBeginLo<wbr>c, ElemTy,<br>
                           diag::err_invalid_incomplete_<wbr>type_use, FullRange))<br>
     return ExprError();<br>
<br>
+  //   Otherwise, the expression is a prvalue of the specified type whose<br>
+  //   result object is direct-initialized (11.6) with the initializer.<br>
   InitializationSequence InitSeq(*this, Entity, Kind, Exprs);<br>
   ExprResult Result = InitSeq.Perform(*this, Entity, Kind, Exprs);<br>
<br>
-  if (Result.isInvalid() || !ListInitialization)<br>
+  if (Result.isInvalid())<br>
     return Result;<br>
<br>
   Expr *Inner = Result.get();<br>
   if (CXXBindTemporaryExpr *BTE = dyn_cast_or_null<CXXBindTempor<wbr>aryExpr>(Inner))<br>
     Inner = BTE->getSubExpr();<br>
-  if (!isa<CXXTemporaryObjectExpr>(<wbr>Inner)) {<br>
+  if (!isa<CXXTemporaryObjectExpr>(<wbr>Inner) &&<br>
+      !isa<CXXScalarValueInitExpr>(I<wbr>nner)) {<br>
     // If we created a CXXTemporaryObjectExpr, that node also represents the<br>
     // functional cast. Otherwise, create an explicit cast to represent<br>
     // the syntactic form of a functional-style cast that was used here.<br>
@@ -1590,20 +1584,8 @@ Sema::ActOnCXXNew(SourceLocati<wbr>on StartLo<br>
     return ExprError();<br>
<br>
   SourceRange DirectInitRange;<br>
-  if (ParenListExpr *List = dyn_cast_or_null<ParenListExpr<wbr>>(Initializer)) {<br>
+  if (ParenListExpr *List = dyn_cast_or_null<ParenListExpr<wbr>>(Initializer))<br>
     DirectInitRange = List->getSourceRange();<br>
-    // Handle errors like: new int a({0})<br>
-    if (List->getNumExprs() == 1 &&<br>
-        !canInitializeWithParenthesize<wbr>dList(AllocType))<br>
-      if (auto IList = dyn_cast<InitListExpr>(List->g<wbr>etExpr(0))) {<br>
-        Diag(TInfo->getTypeLoc().getLo<wbr>cStart(), diag::err_list_init_in_parens)<br>
-            << AllocType << List->getSourceRange()<br>
-            << FixItHint::CreateRemoval(List-<wbr>>getLocStart())<br>
-            << FixItHint::CreateRemoval(List-<wbr>>getLocEnd());<br>
-        DirectInitRange = SourceRange();<br>
-        Initializer = IList;<br>
-      }<br>
-  }<br>
<br>
   return BuildCXXNew(SourceRange(StartL<wbr>oc, D.getLocEnd()), UseGlobal,<br>
                      PlacementLParen,<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaInit.cp<wbr>p<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=298676&r1=298675&r2=298676&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/Sema/SemaI<wbr>nit.cpp?rev=298676&r1=298675&<wbr>r2=298676&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Sema/SemaInit.cp<wbr>p (original)<br>
+++ cfe/trunk/lib/Sema/SemaInit.cp<wbr>p Thu Mar 23 20:14:25 2017<br>
@@ -3112,6 +3112,7 @@ bool InitializationSequence::isAmbi<wbr>guous<br>
<br>
   switch (getFailureKind()) {<br>
   case FK_TooManyInitsForReference:<br>
+  case FK_ParenthesizedListInitForRef<wbr>erence:<br>
   case FK_ArrayNeedsInitList:<br>
   case FK_ArrayNeedsInitListOrStringL<wbr>iteral:<br>
   case FK_ArrayNeedsInitListOrWideStr<wbr>ingLiteral:<br>
@@ -3129,6 +3130,7 @@ bool InitializationSequence::isAmbi<wbr>guous<br>
   case FK_ConversionFailed:<br>
   case FK_ConversionFromPropertyFaile<wbr>d:<br>
   case FK_TooManyInitsForScalar:<br>
+  case FK_ParenthesizedListInitForSca<wbr>lar:<br>
   case FK_ReferenceBindingToInitList:<br>
   case FK_InitListBadDestinationType:<br>
   case FK_DefaultInitOfConst:<br>
@@ -5179,6 +5181,12 @@ void InitializationSequence::Initia<wbr>lizeF<br>
     // (Therefore, multiple arguments are not permitted.)<br>
     if (Args.size() != 1)<br>
       SetFailed(FK_TooManyInitsForR<wbr>eference);<br>
+    // C++17 [dcl.init.ref]p5:<br>
+    //   A reference [...] is initialized by an expression [...] as follows:<br>
+    // If the initializer is not an expression, presumably we should reject,<br>
+    // but the standard fails to actually say so.<br>
+    else if (isa<InitListExpr>(Args[0]))<br>
+      SetFailed(FK_ParenthesizedList<wbr>InitForReference);<br>
     else<br>
       TryReferenceInitialization(S, Entity, Kind, Args[0], *this);<br>
     return;<br>
@@ -5344,11 +5352,16 @@ void InitializationSequence::Initia<wbr>lizeF<br>
     return;<br>
   }<br>
<br>
+  assert(Args.size() >= 1 && "Zero-argument case handled above");<br>
+<br>
+  // The remaining cases all need a source type.<br>
   if (Args.size() > 1) {<br>
     SetFailed(FK_TooManyInitsForS<wbr>calar);<br>
     return;<br>
+  } else if (isa<InitListExpr>(Args[0])) {<br>
+    SetFailed(FK_ParenthesizedList<wbr>InitForScalar);<br>
+    return;<br>
   }<br>
-  assert(Args.size() == 1 && "Zero-argument case handled above");<br>
<br>
   //    - Otherwise, if the source type is a (possibly cv-qualified) class<br>
   //      type, conversion functions are considered.<br>
@@ -7389,6 +7402,10 @@ bool InitializationSequence::Diagno<wbr>se(Se<br>
       S.Diag(Kind.getLocation(), diag::err_reference_has_multip<wbr>le_inits)<br>
         << SourceRange(Args.front()->getL<wbr>ocStart(), Args.back()->getLocEnd());<br>
     break;<br>
+  case FK_ParenthesizedListInitForRef<wbr>erence:<br>
+    S.Diag(Kind.getLocation(), diag::err_list_init_in_parens)<br>
+      << 1 << Entity.getType() << Args[0]->getSourceRange();<br>
+    break;<br>
<br>
   case FK_ArrayNeedsInitList:<br>
     S.Diag(Kind.getLocation(), diag::err_array_init_not_init_<wbr>list) << 0;<br>
@@ -7600,6 +7617,11 @@ bool InitializationSequence::Diagno<wbr>se(Se<br>
     break;<br>
   }<br>
<br>
+  case FK_ParenthesizedListInitForSca<wbr>lar:<br>
+    S.Diag(Kind.getLocation(), diag::err_list_init_in_parens)<br>
+      << 0 << Entity.getType() << Args[0]->getSourceRange();<br>
+    break;<br>
+<br>
   case FK_ReferenceBindingToInitList:<br>
     S.Diag(Kind.getLocation(), diag::err_reference_bind_init_<wbr>list)<br>
       << DestType.getNonReferenceType() << Args[0]->getSourceRange();<br>
@@ -7782,6 +7804,10 @@ void InitializationSequence::dump(r<wbr>aw_os<br>
       OS << "too many initializers for reference";<br>
       break;<br>
<br>
+    case FK_ParenthesizedListInitForRef<wbr>erence:<br>
+      OS << "parenthesized list init for reference";<br>
+      break;<br>
+<br>
     case FK_ArrayNeedsInitList:<br>
       OS << "array requires initializer list";<br>
       break;<br>
@@ -7866,6 +7892,10 @@ void InitializationSequence::dump(r<wbr>aw_os<br>
       OS << "too many initializers for scalar";<br>
       break;<br>
<br>
+    case FK_ParenthesizedListInitForSca<wbr>lar:<br>
+      OS << "parenthesized list init for reference";<br>
+      break;<br>
+<br>
     case FK_ReferenceBindingToInitList:<br>
       OS << "referencing binding to initializer list";<br>
       break;<br>
<br>
Modified: cfe/trunk/test/SemaCXX/cxx0x-i<wbr>nitializer-constructor.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-initializer-constructor.cpp?rev=298676&r1=298675&r2=298676&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/test/SemaCXX/<wbr>cxx0x-initializer-constructor.<wbr>cpp?rev=298676&r1=298675&r2=<wbr>298676&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/SemaCXX/cxx0x-i<wbr>nitializer-constructor.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/cxx0x-i<wbr>nitializer-constructor.cpp Thu Mar 23 20:14:25 2017<br>
@@ -173,8 +173,7 @@ namespace objects {<br>
     // invalid<br>
     H h1({1, 2}); // expected-error {{no matching constructor}}<br>
     (void) new H({1, 2}); // expected-error {{no matching constructor}}<br>
-    // FIXME: Bad diagnostic, mentions void type instead of init list.<br>
-    (void) H({1, 2}); // expected-error {{no matching conversion}}<br>
+    (void) H({1, 2}); // expected-error {{no matching constructor}}<br>
<br>
     // valid (by copy constructor).<br>
     H h2({1, nullptr});<br>
<br>
Modified: cfe/trunk/test/SemaCXX/cxx0x-i<wbr>nitializer-references.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-initializer-references.cpp?rev=298676&r1=298675&r2=298676&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/test/SemaCXX/<wbr>cxx0x-initializer-references.<wbr>cpp?rev=298676&r1=298675&r2=<wbr>298676&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/SemaCXX/cxx0x-i<wbr>nitializer-references.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/cxx0x-i<wbr>nitializer-references.cpp Thu Mar 23 20:14:25 2017<br>
@@ -71,10 +71,22 @@ namespace reference {<br>
     static_assert(sizeof(h({1, 2})) == sizeof(two), "bad overload resolution");<br>
   }<br>
<br>
+  struct X {};<br>
+<br>
   void edge_cases() {<br>
-    int const &b({0}); // expected-error {{list-initializer for non-class type 'const int &' must not be parenthesized}}<br>
-    const int (&arr)[3] ({1, 2, 3}); // expected-error {{list-initializer for non-class type 'const int (&)[3]' must not be parenthesized}}<br>
+    int const &b({0}); // expected-error {{cannot initialize reference type 'const int &' with a parenthesized initializer list}}<br>
+    const int (&arr)[3] ({1, 2, 3}); // expected-error {{cannot initialize reference type 'const int (&)[3]' with a parenthesized initializer list}}<br>
+    const X &x({}); // expected-error {{cannot initialize reference type 'const reference::X &' with a parenthesized initializer list}}<br>
+  }<br>
+<br>
+  template<typename T> void dependent_edge_cases() {<br>
+    T b({}); // expected-error-re 3{{cannot initialize reference type {{.*}} with a parenthesized init}}<br>
+    T({}); // expected-error-re 3{{cannot initialize reference type {{.*}} with a parenthesized init}}<br>
   }<br>
+  template void dependent_edge_cases<X>(); // ok<br>
+  template void dependent_edge_cases<const int&>(); // expected-note {{instantiation of}}<br>
+  template void dependent_edge_cases<const int(&)[1]>(); // expected-note {{instantiation of}}<br>
+  template void dependent_edge_cases<const X&>(); // expected-note {{instantiation of}}<br>
 }<br>
<br>
 namespace PR12182 {<br>
<br>
Modified: cfe/trunk/test/SemaCXX/cxx0x-i<wbr>nitializer-scalars.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-initializer-scalars.cpp?rev=298676&r1=298675&r2=298676&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/test/SemaCXX/<wbr>cxx0x-initializer-scalars.cpp?<wbr>rev=298676&r1=298675&r2=<wbr>298676&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/SemaCXX/cxx0x-i<wbr>nitializer-scalars.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/cxx0x-i<wbr>nitializer-scalars.cpp Thu Mar 23 20:14:25 2017<br>
@@ -91,13 +91,13 @@ namespace integral {<br>
   }<br>
<br>
   void edge_cases() {<br>
-    int a({0}); // expected-error {{list-initializer for non-class type 'int' must not be parenthesized}}<br>
-    (void) int({0}); // expected-error {{list-initializer for non-class type 'int' must not be parenthesized}}<br>
-    new int({0});  // expected-error {{list-initializer for non-class type 'int' must not be parenthesized}}<br>
+    int a({0}); // expected-error {{cannot initialize non-class type 'int' with a parenthesized initializer list}}<br>
+    (void) int({0}); // expected-error {{cannot initialize non-class type 'int' with a parenthesized initializer list}}<br>
+    new int({0});  // expected-error {{cannot initialize non-class type 'int' with a parenthesized initializer list}}<br>
<br>
-    int *b({0});  // expected-error {{list-initializer for non-class type 'int *' must not be parenthesized}}<br>
+    int *b({0});  // expected-error {{cannot initialize non-class type 'int *' with a parenthesized initializer list}}<br>
     typedef int *intptr;<br>
-    int *c = intptr({0});  // expected-error {{list-initializer for non-class type 'intptr' (aka 'int *') must not be parenthesized}}<br>
+    int *c = intptr({0});  // expected-error {{cannot initialize non-class type 'intptr' (aka 'int *') with a parenthesized initializer list}}<br>
   }<br>
<br>
   template<typename T> void dependent_edge_cases() {<br>
<br>
Modified: cfe/trunk/test/SemaCXX/type-co<wbr>nvert-construct.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/type-convert-construct.cpp?rev=298676&r1=298675&r2=298676&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/test/SemaCXX/<wbr>type-convert-construct.cpp?<wbr>rev=298676&r1=298675&r2=<wbr>298676&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/SemaCXX/type-co<wbr>nvert-construct.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/type-co<wbr>nvert-construct.cpp Thu Mar 23 20:14:25 2017<br>
@@ -8,7 +8,15 @@ void f() {<br>
   typedef int arr[];<br>
   int v3 = arr(); // expected-error {{array types cannot be value-initialized}}<br>
   typedef void fn_ty();<br>
-  fn_ty(); // expected-error {{function types cannot be value-initialized}}<br>
+  fn_ty(); // expected-error {{cannot create object of function type 'fn_ty'}}<br>
+  fn_ty(0); // expected-error {{functional-style cast from 'int' to 'fn_ty'}}<br>
+  fn_ty(0, 0); // expected-error {{cannot create object of function type 'fn_ty'}}<br>
+#if __cplusplus >= 201103L<br>
+  fn_ty{}; // expected-error {{cannot create object of function type 'fn_ty'}}<br>
+  fn_ty{0}; // expected-error {{cannot create object of function type 'fn_ty'}}<br>
+  fn_ty{0, 0}; // expected-error {{cannot create object of function type 'fn_ty'}}<br>
+  fn_ty({}); // expected-error {{cannot create object of function type 'fn_ty'}}<br>
+#endif<br>
   int v4 = int();<br>
   int v5 = int; // expected-error {{expected '(' for function-style cast or type construction}}<br>
   typedef int T;<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>
</blockquote></div></div>