[llvm-branch-commits] [clang] ad815b6 - [Clang][Sema] Fix invalid cast when validating SVE types within CheckVariableDeclarationType.

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed May 31 20:09:27 PDT 2023


Author: Paul Walker
Date: 2023-05-31T20:09:11-07:00
New Revision: ad815b672d2233943c20ab9db23698f07a7d7a87

URL: https://github.com/llvm/llvm-project/commit/ad815b672d2233943c20ab9db23698f07a7d7a87
DIFF: https://github.com/llvm/llvm-project/commit/ad815b672d2233943c20ab9db23698f07a7d7a87.diff

LOG: [Clang][Sema] Fix invalid cast when validating SVE types within CheckVariableDeclarationType.

Fixes #62087

Differential Revision: https://reviews.llvm.org/D148919

(cherry picked from commit 2bb7e00b098cdbf87b9e2e2f5ec85b661664b709)

Added: 
    clang/test/SemaOpenMP/arm-sve-acle-types.cpp

Modified: 
    clang/lib/Sema/SemaDecl.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 051fad04219f..0fbef1cc8b52 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -8693,7 +8693,7 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) {
   }
 
   // Check that SVE types are only used in functions with SVE available.
-  if (T->isSVESizelessBuiltinType() && CurContext->isFunctionOrMethod()) {
+  if (T->isSVESizelessBuiltinType() && isa<FunctionDecl>(CurContext)) {
     const FunctionDecl *FD = cast<FunctionDecl>(CurContext);
     llvm::StringMap<bool> CallerFeatureMap;
     Context.getFunctionFeatureMap(CallerFeatureMap, FD);

diff  --git a/clang/test/SemaOpenMP/arm-sve-acle-types.cpp b/clang/test/SemaOpenMP/arm-sve-acle-types.cpp
new file mode 100644
index 000000000000..7afa6e9da24d
--- /dev/null
+++ b/clang/test/SemaOpenMP/arm-sve-acle-types.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fopenmp -fsyntax-only -triple aarch64-arm-none-eabi -target-feature +sve -verify %s
+// expected-no-diagnostics
+
+__SVBool_t foo(int);
+
+void test() {
+#pragma omp parallel
+  {
+    __SVBool_t pg = foo(1);
+  }
+}


        


More information about the llvm-branch-commits mailing list