Skip to content

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -3423,7 +3423,7 @@ def warn_typecheck_vector_element_sizes_not_equal : Warning<
def err_ext_vector_component_exceeds_length : Error<
"vector component access exceeds type %0">;
def err_ext_vector_component_name_illegal : Error<
"illegal vector component name '%0'">;
"illegal vector component name %0">;
def err_attribute_address_space_negative : Error<
"address space is negative">;
def err_attribute_address_space_too_high : Error<
Expand Down
7 changes: 5 additions & 2 deletions clang/lib/Sema/SemaExprMember.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,11 @@ CheckExtVectorComponent(Sema &S, QualType baseType, ExprValueKind &VK,
if (!HalvingSwizzle && *compStr) {
// We didn't get to the end of the string. This means the component names
// didn't come from the same set *or* we encountered an illegal name.
S.Diag(OpLoc, diag::err_ext_vector_component_name_illegal)
<< StringRef(compStr, 1) << SourceRange(CompLoc);
size_t Offset = compStr - CompName->getNameStart() + 1;
char Fmt[3] = {'\'', *compStr, '\''};
S.Diag(OpLoc.getLocWithOffset(Offset),
diag::err_ext_vector_component_name_illegal)
<< StringRef(Fmt, 3) << SourceRange(CompLoc);
return QualType();
}

Expand Down
8 changes: 4 additions & 4 deletions clang/test/SemaCXX/vector-bool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Loading