https://github.com/DhanashreePetare updated 
https://github.com/llvm/llvm-project/pull/174092

>From 4eb5bb3b2bae22efc04e6f0edde649b1d797735b Mon Sep 17 00:00:00 2001
From: DhanashreePetare <[email protected]>
Date: Wed, 31 Dec 2025 19:05:59 +0530
Subject: [PATCH] Sema: handle adjusted function types;add regression test for
 __typeof+__asm+noreturn(#173598)

Signed-off-by: DhanashreePetare <[email protected]>
---
 clang/lib/Sema/SemaDecl.cpp           | 17 ++++++++++++++---
 clang/test/Sema/typeof-asm-noreturn.c | 10 ++++++++++
 2 files changed, 24 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/Sema/typeof-asm-noreturn.c

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index f636e8e35a3d5..0941e2e4a6bb0 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9529,12 +9529,23 @@ static FunctionDecl *CreateNewFunctionDecl(Sema 
&SemaRef, Declarator &D,
     //     declarator to still have a function type. e.g.,
     //       typedef void func(int a);
     //       __attribute__((noreturn)) func other_func; // This has a prototype
+    auto HasFunctionPrototype = [&](QualType T) -> bool {
+      if (T.isNull())
+        return false;
+      if (T->getAs<FunctionProtoType>())
+        return true;
+      if (const FunctionType *Adjusted = T->getAsAdjusted<FunctionType>())
+        return isa<FunctionProtoType>(Adjusted);
+      return false;
+    };
+
     bool HasPrototype =
         (D.isFunctionDeclarator() && D.getFunctionTypeInfo().hasPrototype) ||
         (D.getDeclSpec().isTypeRep() &&
-         SemaRef.GetTypeFromParser(D.getDeclSpec().getRepAsType(), nullptr)
-             ->isFunctionProtoType()) ||
-        (!R->getAsAdjusted<FunctionType>() && R->isFunctionProtoType());
+         HasFunctionPrototype(
+           SemaRef.GetTypeFromParser(D.getDeclSpec().getRepAsType(),
+                         nullptr))) ||
+        HasFunctionPrototype(R);
     assert(
         (HasPrototype || !SemaRef.getLangOpts().requiresStrictPrototypes()) &&
         "Strict prototypes are required");
diff --git a/clang/test/Sema/typeof-asm-noreturn.c 
b/clang/test/Sema/typeof-asm-noreturn.c
new file mode 100644
index 0000000000000..c96d10b2ea6e6
--- /dev/null
+++ b/clang/test/Sema/typeof-asm-noreturn.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -std=c2x -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+int memcmp(const void *, const void *, unsigned long);
+
+__typeof(memcmp) memcmp_alias __asm__("memory_compare") 
__attribute__((noreturn));
+
+void use(void) {
+  (void)memcmp_alias(0, 0, 0);
+}

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to