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

Paul Walker via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 21 05:39:54 PDT 2023


paulwalker-arm created this revision.
Herald added a subscriber: tschuett.
Herald added a project: All.
paulwalker-arm requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, jplehr, sstefan1.
Herald added a project: clang.

Fixes #62087


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148919

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaOpenMP/arm-sve-acle-types.cpp


Index: clang/test/SemaOpenMP/arm-sve-acle-types.cpp
===================================================================
--- /dev/null
+++ 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);
+  }
+}
Index: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -8705,7 +8705,7 @@
   }
 
   // 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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148919.515696.patch
Type: text/x-patch
Size: 1022 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230421/27186b30/attachment.bin>


More information about the cfe-commits mailing list