[clang] [clang] Improve bit-field in ref NTTP diagnostic (PR #71077)

Andrey Ali Khan Bolshakov via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 3 08:06:04 PST 2023


================
@@ -5992,6 +5992,15 @@ static ExprResult BuildConvertedConstantExpression(Sema &S, Expr *From,
                                   /*InOverloadResolution=*/false,
                                   /*AllowObjCWritebackConversion=*/false,
                                   /*AllowExplicit=*/false);
+
+  // TryCopyInitialization returns incorrect info for attempts to bind reference
+  // to bit-field due to C++ [over.ics.ref]p4, so check it here.
+  if (From->refersToBitField() && T.getTypePtr()->isReferenceType()) {
+    return S.Diag(From->getBeginLoc(),
+                  diag::err_reference_bind_to_bitfield_in_cce)
+           << From->getSourceRange();
+  }
----------------
bolshakov-a wrote:

This citation is already present here. I've moved the new code closer to the last cited piece.

https://github.com/llvm/llvm-project/pull/71077


More information about the cfe-commits mailing list