Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 23 Jul 2023 18:27:11 GMT
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: e0c3c6130c9b - stable/13 - Merge commit 69d42eef4bec from llvm-project (by Dimitry Andric):
Message-ID:  <202307231827.36NIRB9i058811@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=e0c3c6130c9bf6d1fa66061b49ee4fb6c3572d55

commit e0c3c6130c9bf6d1fa66061b49ee4fb6c3572d55
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-06-14 18:49:59 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-07-23 17:38:10 +0000

    Merge commit 69d42eef4bec from llvm-project (by Dimitry Andric):
    
      [Clang] Show type in enum out of range diagnostic
    
      When the diagnostic for an out of range enum value is printed, it
      currently does not show the actual enum type in question, for example:
    
          v8/src/base/bit-field.h:43:29: error: integer value 7 is outside the valid range of values [0, 3] for this enumeration type [-Wenum-constexpr-conversion]
            static constexpr T kMax = static_cast<T>(kNumValues - 1);
                                      ^
    
      This can make it cumbersome to find the cause for the problem. Add the
      enum type to the diagnostic message, to make it easier.
    
      Reviewed By: aaron.ballman
    
      Differential Revision: https://reviews.llvm.org/D152788
    
    PR:             271047
    MFC after:      1 month
    
    (cherry picked from commit cf24393421ca807899c599a53ddc5dcedb7c71dc)
---
 .../llvm-project/clang/include/clang/Basic/DiagnosticASTKinds.td | 4 ++--
 contrib/llvm-project/clang/lib/AST/ExprConstant.cpp              | 9 +++++----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticASTKinds.td b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticASTKinds.td
index 28120d13fd9e..4e2e0bd3079c 100644
--- a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticASTKinds.td
+++ b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticASTKinds.td
@@ -393,8 +393,8 @@ def warn_fixedpoint_constant_overflow : Warning<
   "overflow in expression; result is %0 with type %1">,
   InGroup<DiagGroup<"fixed-point-overflow">>;
 def warn_constexpr_unscoped_enum_out_of_range : Warning<
-  "integer value %0 is outside the valid range of values [%1, %2] for this "
-  "enumeration type">, DefaultError, InGroup<DiagGroup<"enum-constexpr-conversion">>;
+  "integer value %0 is outside the valid range of values [%1, %2] for the "
+  "enumeration type %3">, DefaultError, InGroup<DiagGroup<"enum-constexpr-conversion">>;
 
 // This is a temporary diagnostic, and shall be removed once our
 // implementation is complete, and like the preceding constexpr notes belongs
diff --git a/contrib/llvm-project/clang/lib/AST/ExprConstant.cpp b/contrib/llvm-project/clang/lib/AST/ExprConstant.cpp
index 464104139cb2..db6c07d4ab7f 100644
--- a/contrib/llvm-project/clang/lib/AST/ExprConstant.cpp
+++ b/contrib/llvm-project/clang/lib/AST/ExprConstant.cpp
@@ -13682,12 +13682,13 @@ bool IntExprEvaluator::VisitCastExpr(const CastExpr *E) {
           Info.Ctx.getDiagnostics().Report(
               E->getExprLoc(), diag::warn_constexpr_unscoped_enum_out_of_range)
               << llvm::toString(Result.getInt(), 10) << Min.getSExtValue()
-              << Max.getSExtValue();
+              << Max.getSExtValue() << ED;
         else if (!ED->getNumNegativeBits() && ConstexprVar &&
                  Max.ult(Result.getInt().getZExtValue()))
-          Info.Ctx.getDiagnostics().Report(E->getExprLoc(),
-                                       diag::warn_constexpr_unscoped_enum_out_of_range)
-	    << llvm::toString(Result.getInt(),10) << Min.getZExtValue() << Max.getZExtValue();
+          Info.Ctx.getDiagnostics().Report(
+              E->getExprLoc(), diag::warn_constexpr_unscoped_enum_out_of_range)
+              << llvm::toString(Result.getInt(), 10) << Min.getZExtValue()
+              << Max.getZExtValue() << ED;
       }
     }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202307231827.36NIRB9i058811>