[clang] 2bb7e00 - [Clang][Sema] Fix invalid cast when validating SVE types within CheckVariableDeclarationType.

Paul Walker via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 24 05:46:24 PDT 2023


Author: Paul Walker
Date: 2023-04-24T12:45:19Z
New Revision: 2bb7e00b098cdbf87b9e2e2f5ec85b661664b709

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

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

Fixes #62087

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

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 575459c3c6920..719215d3f38c4 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -8705,7 +8705,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 0000000000000..7afa6e9da24da
--- /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 cfe-commits mailing list