[AST] Fix a crash on a dependent vector_size attribute
authorErik Pilkington <erik.pilkington@gmail.com>
Tue, 28 Apr 2020 16:24:54 +0000 (12:24 -0400)
committerErik Pilkington <erik.pilkington@gmail.com>
Tue, 28 Apr 2020 16:54:49 +0000 (12:54 -0400)
Looks like this was just a copy & paste mistake from
getDependentSizedExtVectorType. rdar://60092165

Differential revision: https://reviews.llvm.org/D79012

clang/lib/AST/ASTContext.cpp
clang/test/SemaCXX/vector.cpp

index 47834d4..9b07a88 100644 (file)
@@ -3694,10 +3694,10 @@ ASTContext::getDependentVectorType(QualType VecType, Expr *SizeExpr,
       (void)CanonCheck;
       DependentVectorTypes.InsertNode(New, InsertPos);
     } else {
-      QualType CanonExtTy = getDependentSizedExtVectorType(CanonVecTy, SizeExpr,
-                                                           SourceLocation());
+      QualType CanonTy = getDependentVectorType(CanonVecTy, SizeExpr,
+                                                SourceLocation(), VecKind);
       New = new (*this, TypeAlignment) DependentVectorType(
-          *this, VecType, CanonExtTy, SizeExpr, AttrLoc, VecKind);
+          *this, VecType, CanonTy, SizeExpr, AttrLoc, VecKind);
     }
   }
 
index caa8405..0c143ba 100644 (file)
@@ -475,3 +475,12 @@ void use() {
 #endif // __cplusplus >= 201103L
 }
 }
+
+namespace rdar60092165 {
+template <class T> void f() {
+  typedef T first_type __attribute__((vector_size(sizeof(T) * 4)));
+  typedef T second_type __attribute__((vector_size(sizeof(T) * 4)));
+
+  second_type st;
+}
+}