[PATCH] D122748: [Sema] Don't check bounds for function pointer
    Aleksandr Platonov via Phabricator via cfe-commits 
    cfe-commits at lists.llvm.org
       
    Wed Mar 30 12:17:35 PDT 2022
    
    
  
ArcsinX updated this revision to Diff 419242.
ArcsinX added a comment.
Check for function type only if IsUnboundedArray is true
Repository:
  rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122748/new/
https://reviews.llvm.org/D122748
Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/unbounded-array-bounds.c
Index: clang/test/Sema/unbounded-array-bounds.c
===================================================================
--- clang/test/Sema/unbounded-array-bounds.c
+++ clang/test/Sema/unbounded-array-bounds.c
@@ -80,3 +80,7 @@
   (void *)0 + 0xdead000000000000UL;
   // no array-bounds warning, and no crash
 }
+
+void func() {
+  func + 0xdead000000000000UL; // no crash
+}
Index: clang/lib/Sema/SemaChecking.cpp
===================================================================
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -15468,6 +15468,8 @@
     ND = ME->getMemberDecl();
 
   if (IsUnboundedArray) {
+    if (EffectiveType->isFunctionType())
+      return;
     if (index.isUnsigned() || !index.isNegative()) {
       const auto &ASTC = getASTContext();
       unsigned AddrBits =
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122748.419242.patch
Type: text/x-patch
Size: 816 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220330/146f64da/attachment.bin>
    
    
More information about the cfe-commits
mailing list