[clang] Fix double-quotes in diagnostic when attempting to access a ext_vector of bools (PR #118186)

2024-12-20 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr closed 
https://github.com/llvm/llvm-project/pull/118186
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix double-quotes in diagnostic when attempting to access a ext_vector of bools (PR #118186)

2024-12-20 Thread Timm Baeder via cfe-commits

tbaederr wrote:

Do you need someone to push this?

https://github.com/llvm/llvm-project/pull/118186
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix double-quotes in diagnostic when attempting to access a ext_vector of bools (PR #118186)

2024-12-16 Thread William Tran-Viet via cfe-commits

https://github.com/smallp-o-p edited 
https://github.com/llvm/llvm-project/pull/118186
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix double-quotes in diagnostic when attempting to access a ext_vector of bools (PR #118186)

2024-12-16 Thread William Tran-Viet via cfe-commits

https://github.com/smallp-o-p edited 
https://github.com/llvm/llvm-project/pull/118186
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix double-quotes in diagnostic when attempting to access a ext_vector of bools (PR #118186)

2024-12-16 Thread William Tran-Viet via cfe-commits


@@ -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);

smallp-o-p wrote:

This is the error path for when you try to mix different accessor types on 
openCL vector types, which allows you to access them [with this 
syntax](https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_C.html#vector-components)
 but disallows mixing the different styles.

For example, trying to do something like `.rgbz` where `z` is the bad 
accessor--here we're mixing the `xyzw` access style with the `rgba` access 
style. This should result in an error, as evidenced by the [test(s) 
here](https://github.com/llvm/llvm-project/blob/d866005f6928a2a97e67866bedb26139d8cc27d9/clang/test/Sema/ext_vector_components.c#L46)
  

https://github.com/llvm/llvm-project/pull/118186
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix double-quotes in diagnostic when attempting to access a ext_vector of bools (PR #118186)

2024-12-16 Thread Erich Keane via cfe-commits


@@ -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);

erichkeane wrote:

A quick debug shows the below test changes are a little confusing, as the 
'bool' vectors dont' actually allow anything, so this just ends up diagnosing 
elsewhere.  So this change _IS_ just diagnosing a single letter.

For some reason that I don't quite understand, the access is allowed to be any 
combo of `x`,`y`, `z`, `w`, `r`, `g`,` b`, and `a`, with some attempt to be 
able to 'set' them.  So it seems we're trying to diagnose the first one that 
isn't one of those above letters, so the single letter thing seems fine, just 
confusing for obvious reasons :) 

https://github.com/llvm/llvm-project/pull/118186
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix double-quotes in diagnostic when attempting to access a ext_vector of bools (PR #118186)

2024-12-16 Thread Erich Keane via cfe-commits


@@ -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);

erichkeane wrote:

Can someone explain how this works?  It looks like (both before and after) that 
we're treating the name length as being only 1 (and in this case, 3 after we're 
adding the single quote on both sides).  

BUT it seems in test 91 below that the 'wyx' works, but is 3 characters long.  
Why can't we just print the entirety of the `IdentifierInfo` above?

https://github.com/llvm/llvm-project/pull/118186
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix double-quotes in diagnostic when attempting to access a ext_vector of bools (PR #118186)

2024-12-16 Thread via cfe-commits

https://github.com/cor3ntin approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/118186
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix double-quotes in diagnostic when attempting to access a ext_vector of bools (PR #118186)

2024-12-14 Thread William Tran-Viet via cfe-commits

https://github.com/smallp-o-p updated 
https://github.com/llvm/llvm-project/pull/118186

>From 3b7cf6e65bdfedf8d15e393c9c2f819c4ed70386 Mon Sep 17 00:00:00 2001
From: William Tran-Viet 
Date: Sat, 30 Nov 2024 15:53:32 -0500
Subject: [PATCH 1/4] 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@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() {

>From 664ac70ca6b752eaaca6ee64897885a8e19d84c5 Mon Sep 17 00:00:00 2001
From: William Tran-Viet 
Date: Fri, 13 Dec 2024 22:50:24 -0500
Subject: [PATCH 2/4] Remove quotation marks from
 err_ext_vector_component_name_illegal

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index eb05a6a77978af..3fe837de467cd0 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -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<

>From 1bcf41860a914f66ec31eafc739b4e938363ef3c Mon Sep 17 00:00:00 2001
From: William Tran-Viet 
Date: Fri, 13 Dec 2024 23:53:29 -0500
Subject: [PATCH 3/4] Pass single quotes directly when reporting illegal vector
 component in CheckExtVector(), and offset the diagnostic arrow so it points
 to the offending component, rather than the '.' at the start of the component
 identifier.

---
 clang/lib/Sema/SemaExprMember.cpp | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Sema/SemaExprMember.cpp 
b/clang/lib/Sema/SemaExprMember.cpp
index 3d843bb84d9d8b..70f51efe193b4b 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -434,8 +434,10 @@ 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;
+S.Diag(OpLoc.getLocWithOffset(Offset),
+   diag::err_ext_vector_component_name_illegal)
+<< StringRef({'\'', *compStr, '\''}) << SourceRange(CompLoc);
 return QualType();
   }
 

>From ad89f32758a68e47b45b5ffb4e9abba3e9b809df Mon Sep 17 00:00:00 2001
From: William Tran-Viet 
Date: Sat, 14 Dec 2024 14:43:42 -0500
Subject: [PATCH 4/4] Revert change in ext_vector_type bool element access
 

[clang] Fix double-quotes in diagnostic when attempting to access a ext_vector of bools (PR #118186)

2024-12-14 Thread William Tran-Viet via cfe-commits

https://github.com/smallp-o-p updated 
https://github.com/llvm/llvm-project/pull/118186

>From 3b7cf6e65bdfedf8d15e393c9c2f819c4ed70386 Mon Sep 17 00:00:00 2001
From: William Tran-Viet 
Date: Sat, 30 Nov 2024 15:53:32 -0500
Subject: [PATCH 1/4] 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@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() {

>From 664ac70ca6b752eaaca6ee64897885a8e19d84c5 Mon Sep 17 00:00:00 2001
From: William Tran-Viet 
Date: Fri, 13 Dec 2024 22:50:24 -0500
Subject: [PATCH 2/4] Remove quotation marks from
 err_ext_vector_component_name_illegal

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index eb05a6a77978af..3fe837de467cd0 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -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<

>From 1bcf41860a914f66ec31eafc739b4e938363ef3c Mon Sep 17 00:00:00 2001
From: William Tran-Viet 
Date: Fri, 13 Dec 2024 23:53:29 -0500
Subject: [PATCH 3/4] Pass single quotes directly when reporting illegal vector
 component in CheckExtVector(), and offset the diagnostic arrow so it points
 to the offending component, rather than the '.' at the start of the component
 identifier.

---
 clang/lib/Sema/SemaExprMember.cpp | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Sema/SemaExprMember.cpp 
b/clang/lib/Sema/SemaExprMember.cpp
index 3d843bb84d9d8b..70f51efe193b4b 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -434,8 +434,10 @@ 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;
+S.Diag(OpLoc.getLocWithOffset(Offset),
+   diag::err_ext_vector_component_name_illegal)
+<< StringRef({'\'', *compStr, '\''}) << SourceRange(CompLoc);
 return QualType();
   }
 

>From 5c135e86f37d1b6a80280cbc8d606b9d1ebea54b Mon Sep 17 00:00:00 2001
From: William Tran-Viet 
Date: Sat, 14 Dec 2024 14:43:42 -0500
Subject: [PATCH 4/4] Revert change in ext_vector_type bool element access
 

[clang] Fix double-quotes in diagnostic when attempting to access a ext_vector of bools (PR #118186)

2024-12-13 Thread William Tran-Viet via cfe-commits

https://github.com/smallp-o-p updated 
https://github.com/llvm/llvm-project/pull/118186

>From 3b7cf6e65bdfedf8d15e393c9c2f819c4ed70386 Mon Sep 17 00:00:00 2001
From: William Tran-Viet 
Date: Sat, 30 Nov 2024 15:53:32 -0500
Subject: [PATCH 1/3] 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@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() {

>From 664ac70ca6b752eaaca6ee64897885a8e19d84c5 Mon Sep 17 00:00:00 2001
From: William Tran-Viet 
Date: Fri, 13 Dec 2024 22:50:24 -0500
Subject: [PATCH 2/3] Remove quotation marks from
 err_ext_vector_component_name_illegal

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index eb05a6a77978af..3fe837de467cd0 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -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<

>From 1bcf41860a914f66ec31eafc739b4e938363ef3c Mon Sep 17 00:00:00 2001
From: William Tran-Viet 
Date: Fri, 13 Dec 2024 23:53:29 -0500
Subject: [PATCH 3/3] Pass single quotes directly when reporting illegal vector
 component in CheckExtVector(), and offset the diagnostic arrow so it points
 to the offending component, rather than the '.' at the start of the component
 identifier.

---
 clang/lib/Sema/SemaExprMember.cpp | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Sema/SemaExprMember.cpp 
b/clang/lib/Sema/SemaExprMember.cpp
index 3d843bb84d9d8b..70f51efe193b4b 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -434,8 +434,10 @@ 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;
+S.Diag(OpLoc.getLocWithOffset(Offset),
+   diag::err_ext_vector_component_name_illegal)
+<< StringRef({'\'', *compStr, '\''}) << SourceRange(CompLoc);
 return QualType();
   }
 

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix double-quotes in diagnostic when attempting to access a ext_vector of bools (PR #118186)

2024-12-13 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 9edbe566bfaff6af03c309ebbb229e6e9a717de3 
805195ccece41dfa2591e7652879b0ded0acc3e9 --extensions cpp -- 
clang/lib/Sema/SemaExprMember.cpp clang/test/SemaCXX/vector-bool.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Sema/SemaExprMember.cpp 
b/clang/lib/Sema/SemaExprMember.cpp
index 394ad775f5..c74d57e5b1 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -434,9 +434,10 @@ 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.
-size_t Offset = compStr - CompName->getNameStart() + 1; 
-S.Diag(OpLoc.getLocWithOffset(Offset), 
diag::err_ext_vector_component_name_illegal)
-  << StringRef({'\'', *compStr, '\''}) << SourceRange(CompLoc);
+size_t Offset = compStr - CompName->getNameStart() + 1;
+S.Diag(OpLoc.getLocWithOffset(Offset),
+   diag::err_ext_vector_component_name_illegal)
+<< StringRef({'\'', *compStr, '\''}) << SourceRange(CompLoc);
 return QualType();
   }
 

``




https://github.com/llvm/llvm-project/pull/118186
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix double-quotes in diagnostic when attempting to access a ext_vector of bools (PR #118186)

2024-12-13 Thread William Tran-Viet via cfe-commits

https://github.com/smallp-o-p edited 
https://github.com/llvm/llvm-project/pull/118186
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix double-quotes in diagnostic when attempting to access a ext_vector of bools (PR #118186)

2024-12-13 Thread William Tran-Viet via cfe-commits

https://github.com/smallp-o-p updated 
https://github.com/llvm/llvm-project/pull/118186

>From 3b7cf6e65bdfedf8d15e393c9c2f819c4ed70386 Mon Sep 17 00:00:00 2001
From: William Tran-Viet 
Date: Sat, 30 Nov 2024 15:53:32 -0500
Subject: [PATCH 1/3] 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@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() {

>From 664ac70ca6b752eaaca6ee64897885a8e19d84c5 Mon Sep 17 00:00:00 2001
From: William Tran-Viet 
Date: Fri, 13 Dec 2024 22:50:24 -0500
Subject: [PATCH 2/3] Remove quotation marks from
 err_ext_vector_component_name_illegal

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index eb05a6a77978af..3fe837de467cd0 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -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<

>From eb073bee82aefba5e6064d97c3e4ebb55032303c Mon Sep 17 00:00:00 2001
From: William Tran-Viet 
Date: Fri, 13 Dec 2024 23:32:53 -0500
Subject: [PATCH 3/3] Pass single quotes directly when reporting illegal vector
 component in CheckExtVector(), and offset the diagnostic arrow so it points
 to the offending component, rather than the '.' at the start of the component
 identifier.

---
 clang/lib/Sema/SemaExprMember.cpp | 318 ++
 1 file changed, 145 insertions(+), 173 deletions(-)

diff --git a/clang/lib/Sema/SemaExprMember.cpp 
b/clang/lib/Sema/SemaExprMember.cpp
index 3d843bb84d9d8b..f2adb8d88c0191 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -25,7 +25,7 @@
 using namespace clang;
 using namespace sema;
 
-typedef llvm::SmallPtrSet BaseSet;
+typedef llvm::SmallPtrSet BaseSet;
 
 /// Determines if the given class is provably not derived from all of
 /// the prospective base classes.
@@ -196,9 +196,8 @@ static IMAKind ClassifyImplicitMemberAccess(Sema &SemaRef,
   // non-static non-type member of some class C [...]
   // ...if C is not X or a base class of X, the class member access expression
   // is ill-formed.
-  if (R.getNamingClass() &&
-  contextClass->getCanonicalDecl() !=
-R.getNamingClass()->getCanonicalDecl()) {
+  if (R.getNamingClass() && contextClass->getCanonicalDecl() !=
+R.getNamingClass()->getCanonicalDecl()) {
 // If the naming class is not the current context, this was a qualified
 // member name lookup, a

[clang] Fix double-quotes in diagnostic when attempting to access a ext_vector of bools (PR #118186)

2024-12-13 Thread William Tran-Viet via cfe-commits

https://github.com/smallp-o-p updated 
https://github.com/llvm/llvm-project/pull/118186

>From 3b7cf6e65bdfedf8d15e393c9c2f819c4ed70386 Mon Sep 17 00:00:00 2001
From: William Tran-Viet 
Date: Sat, 30 Nov 2024 15:53:32 -0500
Subject: [PATCH 1/3] 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@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() {

>From 664ac70ca6b752eaaca6ee64897885a8e19d84c5 Mon Sep 17 00:00:00 2001
From: William Tran-Viet 
Date: Fri, 13 Dec 2024 22:50:24 -0500
Subject: [PATCH 2/3] Remove quotation marks from
 err_ext_vector_component_name_illegal

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index eb05a6a77978af..3fe837de467cd0 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -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<

>From 805195ccece41dfa2591e7652879b0ded0acc3e9 Mon Sep 17 00:00:00 2001
From: William Tran-Viet 
Date: Fri, 13 Dec 2024 23:32:53 -0500
Subject: [PATCH 3/3] Pass single quotes directly when reporting illegal vector
 component in CheckExtVector(), and offset the diagnostic arrow so it points
 to the offending component, rather than the '.' at the start of the component
 identifier.

---
 clang/lib/Sema/SemaExprMember.cpp | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Sema/SemaExprMember.cpp 
b/clang/lib/Sema/SemaExprMember.cpp
index 3d843bb84d9d8b..394ad775f56749 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -434,8 +434,9 @@ 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; 
+S.Diag(OpLoc.getLocWithOffset(Offset), 
diag::err_ext_vector_component_name_illegal)
+  << StringRef({'\'', *compStr, '\''}) << SourceRange(CompLoc);
 return QualType();
   }
 
@@ -1655,10 +1656,8 @@ 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 

[clang] Fix double-quotes in diagnostic when attempting to access a ext_vector of bools (PR #118186)

2024-12-06 Thread Shafik Yaghmour via cfe-commits

https://github.com/shafik commented:

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.

https://github.com/llvm/llvm-project/pull/118186
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix double-quotes in diagnostic when attempting to access a ext_vector of bools (PR #118186)

2024-12-06 Thread William Tran-Viet via cfe-commits

https://github.com/smallp-o-p edited 
https://github.com/llvm/llvm-project/pull/118186
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix double-quotes in diagnostic when attempting to access a ext_vector of bools (PR #118186)

2024-12-06 Thread William Tran-Viet via cfe-commits


@@ -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()

smallp-o-p wrote:

Fair enough. I'll put this back into draft and get to work on that.

Thanks!

https://github.com/llvm/llvm-project/pull/118186
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix double-quotes in diagnostic when attempting to access a ext_vector of bools (PR #118186)

2024-12-06 Thread Erich Keane via cfe-commits


@@ -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()

erichkeane wrote:

I would rather we remove the quotes from the diagnostic, and re-add them in the 
string-ref being passed (OR, better, refactor that part to actually send the 
component rather than the string ref).  Having to do this work to get the 
identifier that should be handled by the diagnostics engine isn't correct IMO.

That is, remove the quotes from the diag, and fix `CheckExtVectorComponent`, 
not make this site worse.

https://github.com/llvm/llvm-project/pull/118186
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix double-quotes in diagnostic when attempting to access a ext_vector of bools (PR #118186)

2024-12-06 Thread William Tran-Viet via cfe-commits


@@ -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()

smallp-o-p wrote:

The reason I did this instead of that was cause in `CheckExtVectorComponent`, a 
`StringRef` is passed to the diagnostics handler, which doesn't add quotes 
around the name, hence why the quotes are in the error message in the first 
place.   

Removing the quotes in `DiagnosticsSemaKind.td` causes the tests in 
`/Sema/ext_vector_components.c` to fail.

The real todo would be to implement modifications for `ak_std_string`. 

Let me know what you think, also thank you for taking the time to look at this. 

https://github.com/llvm/llvm-project/pull/118186
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix double-quotes in diagnostic when attempting to access a ext_vector of bools (PR #118186)

2024-12-06 Thread via cfe-commits


@@ -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()

cor3ntin wrote:

Did you try to remove the quotes in DiagnositicSemaKind.td instead?

https://github.com/llvm/llvm-project/pull/118186
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix double-quotes in diagnostic when attempting to access a ext_vector of bools (PR #118186)

2024-11-30 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: William Tran-Viet (smallp-o-p)


Changes

Fixes #116932 

---
Full diff: https://github.com/llvm/llvm-project/pull/118186.diff


2 Files Affected:

- (modified) clang/lib/Sema/SemaExprMember.cpp (+3-1) 
- (modified) clang/test/SemaCXX/vector-bool.cpp (+4-4) 


``diff
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() {

``




https://github.com/llvm/llvm-project/pull/118186
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix double-quotes in diagnostic when attempting to access a ext_vector of bools (PR #118186)

2024-11-30 Thread William Tran-Viet via cfe-commits

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 
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@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() {

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits