[clang] Fix double-quotes in diagnostic when attempting to access a ext_vector of bools (PR #118186)
William Tran-Viet via cfe-commits
cfe-commits at lists.llvm.org
Sat Nov 30 14:08:12 PST 2024
https://github.com/smallp-o-p created https://github.com/llvm/llvm-project/pull/118186
Fixes #116932
>From 3b7cf6e65bdfedf8d15e393c9c2f819c4ed70386 Mon Sep 17 00:00:00 2001
From: William Tran-Viet <wtranviet at proton.me>
Date: Sat, 30 Nov 2024 15:53:32 -0500
Subject: [PATCH] Fix double-quotes in diagnostic when attempting to access a
ext_vector of bools
---
clang/lib/Sema/SemaExprMember.cpp | 4 +++-
clang/test/SemaCXX/vector-bool.cpp | 8 ++++----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/clang/lib/Sema/SemaExprMember.cpp b/clang/lib/Sema/SemaExprMember.cpp
index 434768b99d631e..3d843bb84d9d8b 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -1655,8 +1655,10 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult &R,
// We disallow element access for ext_vector_type bool. There is no way to
// materialize a reference to a vector element as a pointer (each element is
// one bit in the vector).
+ assert(MemberName.isIdentifier() &&
+ "Ext vector component name not an identifier!");
S.Diag(R.getNameLoc(), diag::err_ext_vector_component_name_illegal)
- << MemberName
+ << MemberName.getAsIdentifierInfo()->getName()
<< (BaseExpr.get() ? BaseExpr.get()->getSourceRange() : SourceRange());
return ExprError();
}
diff --git a/clang/test/SemaCXX/vector-bool.cpp b/clang/test/SemaCXX/vector-bool.cpp
index e99d420e73fab2..cd638056f348b0 100644
--- a/clang/test/SemaCXX/vector-bool.cpp
+++ b/clang/test/SemaCXX/vector-bool.cpp
@@ -85,10 +85,10 @@ void foo(const bool& X);
// Disallow element-wise access.
bool* ElementRefs() {
- eight_bools.y = false; // expected-error at 88 {{illegal vector component name ''y''}}
- &eight_bools.z; // expected-error at 89 {{illegal vector component name ''z''}}
- foo(eight_bools.w); // expected-error at 90 {{illegal vector component name ''w''}}
- foo(eight_bools.wyx); // expected-error at 91 {{illegal vector component name ''wyx''}}
+ eight_bools.y = false; // expected-error at 88 {{illegal vector component name 'y'}}
+ &eight_bools.z; // expected-error at 89 {{illegal vector component name 'z'}}
+ foo(eight_bools.w); // expected-error at 90 {{illegal vector component name 'w'}}
+ foo(eight_bools.wyx); // expected-error at 91 {{illegal vector component name 'wyx'}}
}
void Sizeof() {
More information about the cfe-commits
mailing list