<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-<wbr>project?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/<wbr>Initialization.h<br>
    cfe/trunk/include/clang/Sema/<wbr>Sema.h<br>
    cfe/trunk/lib/Sema/SemaDecl.<wbr>cpp<br>
    cfe/trunk/lib/Sema/<wbr>SemaExprCXX.cpp<br>
    cfe/trunk/lib/Sema/SemaInit.<wbr>cpp<br>
    cfe/trunk/test/SemaCXX/cxx0x-<wbr>initializer-constructor.cpp<br>
    cfe/trunk/test/SemaCXX/cxx0x-<wbr>initializer-references.cpp<br>
    cfe/trunk/test/SemaCXX/cxx0x-<wbr>initializer-scalars.cpp<br>
    cfe/trunk/test/SemaCXX/type-<wbr>convert-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-<wbr>project/cfe/trunk/include/<wbr>clang/Basic/<wbr>DiagnosticSemaKinds.td?rev=<wbr>298676&r1=298675&r2=298676&<wbr>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_<wbr>than_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_<wbr>type : 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/<wbr>Initialization.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-<wbr>project/cfe/trunk/include/<wbr>clang/Sema/Initialization.h?<wbr>rev=298676&r1=298675&r2=<wbr>298676&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/Sema/<wbr>Initialization.h (original)<br>
+++ cfe/trunk/include/clang/Sema/<wbr>Initialization.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_<wbr>ParenthesizedListInitForRefere<wbr>nce,<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_<wbr>ConversionFromPropertyFailed,<br>
     /// \brief Too many initializers for scalar<br>
     FK_TooManyInitsForScalar,<br>
+    /// \brief Scalar initialized from a parenthesized initializer list.<br>
+    FK_<wbr>ParenthesizedListInitForScalar<wbr>,<br>
     /// \brief Reference initialization from an initializer list<br>
     FK_ReferenceBindingToInitList,<br>
     /// \brief Initialization of some unused destination type with an<br>
@@ -892,7 +896,7 @@ public:<br>
     /// having its address taken.<br>
     FK_<wbr>AddressOfUnaddressableFunction<wbr>,<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/<wbr>Sema.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-<wbr>project/cfe/trunk/include/<wbr>clang/Sema/Sema.h?rev=298676&<wbr>r1=298675&r2=298676&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/Sema/<wbr>Sema.h (original)<br>
+++ cfe/trunk/include/clang/Sema/<wbr>Sema.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.<wbr>cpp<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-<wbr>project/cfe/trunk/lib/Sema/<wbr>SemaDecl.cpp?rev=298676&r1=<wbr>298675&r2=298676&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Sema/SemaDecl.<wbr>cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDecl.<wbr>cpp Thu Mar 23 20:14:25 2017<br>
@@ -10102,18 +10102,6 @@ void Sema::AddInitializerToDecl(<wbr>Decl *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>
-        !<wbr>canInitializeWithParenthesized<wbr>List(VDecl->getType()))<br>
-      if (auto IList = dyn_cast<InitListExpr>(<wbr>CXXDirectInit->getExpr(0))) {<br>
-        Diag(VDecl->getLocation(), diag::err_list_init_in_parens)<br>
-            << VDecl->getType() << CXXDirectInit->getSourceRange(<wbr>)<br>
-            << FixItHint::CreateRemoval(<wbr>CXXDirectInit->getLocStart())<br>
-            << FixItHint::CreateRemoval(<wbr>CXXDirectInit->getLocEnd());<br>
-        Init = IList;<br>
-        CXXDirectInit = nullptr;<br>
-      }<br>
-<br>
     InitializedEntity Entity = InitializedEntity::<wbr>InitializeVariable(VDecl);<br>
     InitializationKind Kind = InitializationKind::<wbr>CreateForInit(<br>
         VDecl->getLocation(), DirectInit, Init);<br>
@@ -10413,18 +10401,6 @@ void Sema::ActOnInitializerError(<wbr>Decl *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::<wbr>canInitializeWithParenthesized<wbr>List(QualType TargetType) {<br>
-  return TargetType->isDependentType() || TargetType->isRecordType() ||<br>
-         TargetType-><wbr>getContainedAutoType();<br>
-}<br>
-<br>
 void Sema::ActOnUninitializedDecl(<wbr>Decl *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/<wbr>SemaExprCXX.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-<wbr>project/cfe/trunk/lib/Sema/<wbr>SemaExprCXX.cpp?rev=298676&r1=<wbr>298675&r2=298676&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Sema/<wbr>SemaExprCXX.cpp (original)<br>
+++ cfe/trunk/lib/Sema/<wbr>SemaExprCXX.cpp Thu Mar 23 20:14:25 2017<br>
@@ -1228,17 +1228,6 @@ Sema::<wbr>ActOnCXXTypeConstructExpr(<wbr>ParsedTy<br>
   if (!TInfo)<br>
     TInfo = Context.<wbr>getTrivialTypeSourceInfo(Ty, SourceLocation());<br>
<br>
-  // Handle errors like: int({0})<br>
-  if (exprs.size() == 1 && !<wbr>canInitializeWithParenthesized<wbr>List(Ty) &&<br>
-      LParenLoc.isValid() && RParenLoc.isValid())<br>
-    if (auto IList = dyn_cast<InitListExpr>(exprs[<wbr>0])) {<br>
-      Diag(TInfo->getTypeLoc().<wbr>getLocStart(), diag::err_list_init_in_parens)<br>
-          << Ty << IList->getSourceRange()<br>
-          << FixItHint::CreateRemoval(<wbr>LParenLoc)<br>
-          << FixItHint::CreateRemoval(<wbr>RParenLoc);<br>
-      LParenLoc = RParenLoc = SourceLocation();<br>
-    }<br>
-<br>
   auto Result = BuildCXXTypeConstructExpr(<wbr>TInfo, 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::<wbr>BuildCXXTypeConstructExpr(<wbr>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(<wbr>TInfo, 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_<wbr>array_type) << FullRange);<br>
+      return ExprError(Diag(TyBeginLoc, diag::err_value_init_for_<wbr>array_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_<wbr>function_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_<wbr>type)<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(<wbr>TyBeginLoc, 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<<wbr>CXXBindTemporaryExpr>(Inner))<br>
     Inner = BTE->getSubExpr();<br>
-  if (!isa<CXXTemporaryObjectExpr>(<wbr>Inner)) {<br>
+  if (!isa<CXXTemporaryObjectExpr>(<wbr>Inner) &&<br>
+      !isa<CXXScalarValueInitExpr>(<wbr>Inner)) {<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(<wbr>SourceLocation StartLo<br>
     return ExprError();<br>
<br>
   SourceRange DirectInitRange;<br>
-  if (ParenListExpr *List = dyn_cast_or_null<<wbr>ParenListExpr>(Initializer)) {<br>
+  if (ParenListExpr *List = dyn_cast_or_null<<wbr>ParenListExpr>(Initializer))<br>
     DirectInitRange = List->getSourceRange();<br>
-    // Handle errors like: new int a({0})<br>
-    if (List->getNumExprs() == 1 &&<br>
-        !<wbr>canInitializeWithParenthesized<wbr>List(AllocType))<br>
-      if (auto IList = dyn_cast<InitListExpr>(List-><wbr>getExpr(0))) {<br>
-        Diag(TInfo->getTypeLoc().<wbr>getLocStart(), 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(<wbr>StartLoc, D.getLocEnd()), UseGlobal,<br>
                      PlacementLParen,<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaInit.<wbr>cpp<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-<wbr>project/cfe/trunk/lib/Sema/<wbr>SemaInit.cpp?rev=298676&r1=<wbr>298675&r2=298676&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Sema/SemaInit.<wbr>cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaInit.<wbr>cpp Thu Mar 23 20:14:25 2017<br>
@@ -3112,6 +3112,7 @@ bool InitializationSequence::<wbr>isAmbiguous<br>
<br>
   switch (getFailureKind()) {<br>
   case FK_TooManyInitsForReference:<br>
+  case FK_<wbr>ParenthesizedListInitForRefere<wbr>nce:<br>
   case FK_ArrayNeedsInitList:<br>
   case FK_<wbr>ArrayNeedsInitListOrStringLite<wbr>ral:<br>
   case FK_<wbr>ArrayNeedsInitListOrWideString<wbr>Literal:<br>
@@ -3129,6 +3130,7 @@ bool InitializationSequence::<wbr>isAmbiguous<br>
   case FK_ConversionFailed:<br>
   case FK_<wbr>ConversionFromPropertyFailed:<br>
   case FK_TooManyInitsForScalar:<br>
+  case FK_<wbr>ParenthesizedListInitForScalar<wbr>:<br>
   case FK_ReferenceBindingToInitList:<br>
   case FK_InitListBadDestinationType:<br>
   case FK_DefaultInitOfConst:<br>
@@ -5179,6 +5181,12 @@ void InitializationSequence::<wbr>InitializeF<br>
     // (Therefore, multiple arguments are not permitted.)<br>
     if (Args.size() != 1)<br>
       SetFailed(FK_<wbr>TooManyInitsForReference);<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_<wbr>ParenthesizedListInitForRefere<wbr>nce);<br>
     else<br>
       TryReferenceInitialization(S, Entity, Kind, Args[0], *this);<br>
     return;<br>
@@ -5344,11 +5352,16 @@ void InitializationSequence::<wbr>InitializeF<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_<wbr>TooManyInitsForScalar);<br>
     return;<br>
+  } else if (isa<InitListExpr>(Args[0])) {<br>
+    SetFailed(FK_<wbr>ParenthesizedListInitForScalar<wbr>);<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::<wbr>Diagnose(Se<br>
       S.Diag(Kind.getLocation(), diag::err_reference_has_<wbr>multiple_inits)<br>
         << SourceRange(Args.front()-><wbr>getLocStart(), Args.back()->getLocEnd());<br>
     break;<br>
+  case FK_<wbr>ParenthesizedListInitForRefere<wbr>nce:<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::<wbr>Diagnose(Se<br>
     break;<br>
   }<br>
<br>
+  case FK_<wbr>ParenthesizedListInitForScalar<wbr>:<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(<wbr>raw_os<br>
       OS << "too many initializers for reference";<br>
       break;<br>
<br>
+    case FK_<wbr>ParenthesizedListInitForRefere<wbr>nce:<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(<wbr>raw_os<br>
       OS << "too many initializers for scalar";<br>
       break;<br>
<br>
+    case FK_<wbr>ParenthesizedListInitForScalar<wbr>:<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-<wbr>initializer-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-<wbr>project/cfe/trunk/test/<wbr>SemaCXX/cxx0x-initializer-<wbr>constructor.cpp?rev=298676&r1=<wbr>298675&r2=298676&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/SemaCXX/cxx0x-<wbr>initializer-constructor.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/cxx0x-<wbr>initializer-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-<wbr>initializer-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-<wbr>project/cfe/trunk/test/<wbr>SemaCXX/cxx0x-initializer-<wbr>references.cpp?rev=298676&r1=<wbr>298675&r2=298676&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/SemaCXX/cxx0x-<wbr>initializer-references.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/cxx0x-<wbr>initializer-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-<wbr>initializer-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-<wbr>project/cfe/trunk/test/<wbr>SemaCXX/cxx0x-initializer-<wbr>scalars.cpp?rev=298676&r1=<wbr>298675&r2=298676&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/SemaCXX/cxx0x-<wbr>initializer-scalars.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/cxx0x-<wbr>initializer-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-<wbr>convert-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-<wbr>project/cfe/trunk/test/<wbr>SemaCXX/type-convert-<wbr>construct.cpp?rev=298676&r1=<wbr>298675&r2=298676&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/SemaCXX/type-<wbr>convert-construct.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/type-<wbr>convert-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">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>