[Midnightbsd-cvs] src [11170] trunk/contrib/llvm/tools/clang: check reference type failure

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sat Jun 30 13:16:40 EDT 2018


Revision: 11170
          http://svnweb.midnightbsd.org/src/?rev=11170
Author:   laffer1
Date:     2018-06-30 13:16:39 -0400 (Sat, 30 Jun 2018)
Log Message:
-----------
check reference type failure

Modified Paths:
--------------
    trunk/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
    trunk/contrib/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp
    trunk/contrib/llvm/tools/clang/lib/Sema/SemaInit.cpp

Modified: trunk/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- trunk/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td	2018-06-30 17:15:06 UTC (rev 11169)
+++ trunk/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td	2018-06-30 17:16:39 UTC (rev 11170)
@@ -1419,6 +1419,9 @@
   InGroup<Uninitialized>, DefaultIgnore;
 def note_block_var_fixit_add_initialization : Note<
   "maybe you meant to use __block %0">;
+def note_in_reference_temporary_list_initializer : Note<
+  "in initialization of temporary of type %0 created to "
+  "list-initialize this reference">;
 def note_var_fixit_add_initialization : Note<
   "initialize the variable %0 to silence this warning">;
 def note_uninit_fixit_remove_cond : Note<

Modified: trunk/contrib/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp
===================================================================
--- trunk/contrib/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp	2018-06-30 17:15:06 UTC (rev 11169)
+++ trunk/contrib/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp	2018-06-30 17:16:39 UTC (rev 11170)
@@ -10952,7 +10952,8 @@
 
   StringRef LiteralName
     = FnDecl->getDeclName().getCXXLiteralIdentifier()->getName();
-  if (LiteralName[0] != '_') {
+  if (LiteralName[0] != '_' &&
+      !getSourceManager().isInSystemHeader(FnDecl->getLocation())) {
     // C++11 [usrlit.suffix]p1:
     //   Literal suffix identifiers that do not start with an underscore
     //   are reserved for future standardization.

Modified: trunk/contrib/llvm/tools/clang/lib/Sema/SemaInit.cpp
===================================================================
--- trunk/contrib/llvm/tools/clang/lib/Sema/SemaInit.cpp	2018-06-30 17:15:06 UTC (rev 11169)
+++ trunk/contrib/llvm/tools/clang/lib/Sema/SemaInit.cpp	2018-06-30 17:16:39 UTC (rev 11170)
@@ -6309,6 +6309,19 @@
     return diagnoseListInit(S, HiddenArray, InitList);
   }
 
+  if (DestType->isReferenceType()) {
+    // A list-initialization failure for a reference means that we tried to
+    // create a temporary of the inner type (per [dcl.init.list]p3.6) and the
+    // inner initialization failed.
+    QualType T = DestType->getAs<ReferenceType>()->getPointeeType();
+    diagnoseListInit(S, InitializedEntity::InitializeTemporary(T), InitList);
+    SourceLocation Loc = InitList->getLocStart();
+    if (DeclaratorDecl *D = Entity.getDecl())
+      Loc = D->getLocation();
+    S.Diag(Loc, diag::note_in_reference_temporary_list_initializer) << T;
+    return;
+  }
+
   InitListChecker DiagnoseInitList(S, Entity, InitList, DestType,
                                    /*VerifyOnly=*/false);
   assert(DiagnoseInitList.HadError() &&



More information about the Midnightbsd-cvs mailing list