-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Fix double-quotes in diagnostic when attempting to access a ext_vector of bools #118186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix double-quotes in diagnostic when attempting to access a ext_vector of bools #118186
The head ref may contain hidden characters: "116932-Double-single-quotes-in-\"illegal-vector-component-name\"-diagnostic"
Conversation
|
@llvm/pr-subscribers-clang Author: William Tran-Viet (smallp-o-p) ChangesFixes #116932 Full diff: https://github.com/llvm/llvm-project/pull/118186.diff 2 Files Affected:
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@88 {{illegal vector component name ''y''}}
- &eight_bools.z; // expected-error@89 {{illegal vector component name ''z''}}
- foo(eight_bools.w); // expected-error@90 {{illegal vector component name ''w''}}
- foo(eight_bools.wyx); // expected-error@91 {{illegal vector component name ''wyx''}}
+ eight_bools.y = false; // expected-error@88 {{illegal vector component name 'y'}}
+ &eight_bools.z; // expected-error@89 {{illegal vector component name 'z'}}
+ foo(eight_bools.w); // expected-error@90 {{illegal vector component name 'w'}}
+ foo(eight_bools.wyx); // expected-error@91 {{illegal vector component name 'wyx'}}
}
void Sizeof() {
|
shafik
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution, please add a more detailed summary to your PR. Your summary should if your title describes the problem sufficiently describe how you will fix the problem.
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
805195c to
eb073be
Compare
…n CheckExtVector(), and offset the diagnostic arrow so it points to the offending component, rather than the '.' at the start of the component identifier.
eb073be to
1bcf418
Compare
…use a more explicit StringRef constructor
5c135e8 to
ad89f32
Compare
cor3ntin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
Do you need someone to push this? |
…or-component-name"-diagnostic
|
Yes please. |
Fixes #116932
CheckExtVectorComponentOpLocpassed intoS.Diagso the error message arrow points directly to the offending illegal component rather than to the '.' at the start of the component identifier.vector-bool.cppelement-wise access test case so it (correctly) now only expects a single set of quotes.