Skip to content

Commit ad815b6

Browse files
paulwalker-armtstellar
authored andcommitted
[Clang][Sema] Fix invalid cast when validating SVE types within CheckVariableDeclarationType.
Fixes llvm#62087 Differential Revision: https://reviews.llvm.org/D148919 (cherry picked from commit 2bb7e00)
1 parent cf85b3e commit ad815b6

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

clang/lib/Sema/SemaDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8693,7 +8693,7 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) {
86938693
}
86948694

86958695
// Check that SVE types are only used in functions with SVE available.
8696-
if (T->isSVESizelessBuiltinType() && CurContext->isFunctionOrMethod()) {
8696+
if (T->isSVESizelessBuiltinType() && isa<FunctionDecl>(CurContext)) {
86978697
const FunctionDecl *FD = cast<FunctionDecl>(CurContext);
86988698
llvm::StringMap<bool> CallerFeatureMap;
86998699
Context.getFunctionFeatureMap(CallerFeatureMap, FD);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %clang_cc1 -fopenmp -fsyntax-only -triple aarch64-arm-none-eabi -target-feature +sve -verify %s
2+
// expected-no-diagnostics
3+
4+
__SVBool_t foo(int);
5+
6+
void test() {
7+
#pragma omp parallel
8+
{
9+
__SVBool_t pg = foo(1);
10+
}
11+
}

0 commit comments

Comments
 (0)