[PATCH] D65407: Don't parse elements of extended vectors as template names

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 29 10:27:31 PDT 2019


ahatanak created this revision.
ahatanak added a reviewer: rsmith.
ahatanak added a project: clang.
Herald added subscribers: dexonsmith, jkorous.

This patch attempts to fix the bug introduced in r360308, which is causing clang to reject the following piece of code:

  typedef __attribute__((__ext_vector_type__(2))) float vector_float2;
  
  bool foo123(vector_float2 &A, vector_float2 &B)
  {
    return A.x < B.x && B.y > A.y;
  }

The patch sets `ObjectType` to the type of the extended vector in `Sema::ActOnStartCXXMemberReference` so that `Sema::isTemplateName`, which is called later ,returns false.

rdar://problem/52619956


Repository:
  rC Clang

https://reviews.llvm.org/D65407

Files:
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/vector.cpp


Index: test/SemaCXX/vector.cpp
===================================================================
--- test/SemaCXX/vector.cpp
+++ test/SemaCXX/vector.cpp
@@ -333,4 +333,10 @@
   const PR15730<8, char>::type2 PR15730_2 = {};
 }
 
+// This used to be rejected because the name lookup determined 'x' in 'a.x' was
+// a template name.
+bool templateName(char16_e a, char16_e b) {
+  return a.x < b.x && b.y > a.y;
+}
+
 } // namespace Templates
Index: lib/Sema/SemaExprCXX.cpp
===================================================================
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -6798,7 +6798,15 @@
     ObjectType = ParsedType::make(BaseType);
     MayBePseudoDestructor = true;
     return Base;
-  } else if (!BaseType->isRecordType()) {
+  }
+
+  if (BaseType->isExtVectorType()) {
+    ObjectType = ParsedType::make(BaseType);
+    MayBePseudoDestructor = true;
+    return Base;
+  }
+
+  if (!BaseType->isRecordType()) {
     ObjectType = nullptr;
     MayBePseudoDestructor = true;
     return Base;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65407.212191.patch
Type: text/x-patch
Size: 1032 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190729/1727dc24/attachment.bin>


More information about the cfe-commits mailing list