diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 6ac02df193976a..324a3674732aa0 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -18170,7 +18170,8 @@ ExprResult Sema::VerifyBitField(SourceLocation FieldLoc, // Zero-width bitfield is ok for anonymous field. if (Value == 0 && FieldName) - return Diag(FieldLoc, diag::err_bitfield_has_zero_width) << FieldName; + return Diag(FieldLoc, diag::err_bitfield_has_zero_width) + << FieldName << BitWidth->getSourceRange(); if (Value.isSigned() && Value.isNegative()) { if (FieldName) diff --git a/clang/test/Misc/misc-source-ranges.cpp b/clang/test/Misc/misc-source-ranges.cpp new file mode 100644 index 00000000000000..7a9d9d057dac40 --- /dev/null +++ b/clang/test/Misc/misc-source-ranges.cpp @@ -0,0 +1,7 @@ +// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-print-source-range-info %s 2>&1 | FileCheck %s + +struct S { + char a : 12 - 12; +}; +// CHECK: misc-source-ranges.cpp:[[@LINE-2]]:8:{[[@LINE-2]]:12-[[@LINE-2]]:19} +