[clang] [clang] Sema::isSimpleTypeSpecifier return true for _Bool in c99 (PR #72204)

Carl Peto via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 14 09:34:56 PST 2023


https://github.com/carlos4242 updated https://github.com/llvm/llvm-project/pull/72204

>From 26d40ec42af065fdeda6bdf679cc87928c81c97a Mon Sep 17 00:00:00 2001
From: Carl Peto <carl.peto at me.com>
Date: Tue, 14 Nov 2023 03:50:14 +0000
Subject: [PATCH 1/2] [clang] Sema::isSimpleTypeSpecifier return true for _Bool
 in c99 Currently returns false for _Bool, regardless of C dialect.

Fixes #72203.
---
 clang/lib/Sema/SemaDecl.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 3876eb501083acb..da40b9a1a1b21b9 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -153,6 +153,9 @@ bool Sema::isSimpleTypeSpecifier(tok::TokenKind Kind) const {
   case tok::kw___auto_type:
     return true;
 
+  case tok::kw__Bool:
+    return getLangOpts().C99;
+
   case tok::annot_typename:
   case tok::kw_char16_t:
   case tok::kw_char32_t:

>From a3c5a71f93190204b17bfe01633ef0fa96c5f0ec Mon Sep 17 00:00:00 2001
From: Carl Peto <carl.peto at me.com>
Date: Tue, 14 Nov 2023 17:27:37 +0000
Subject: [PATCH 2/2] [AVR] make the AVR ABI Swift compatible

This patch is needed to add support to clang's AVR ABI for the Swift
language. It is a pre-requisite for upstreaming AVR patches to the Swift
compiler itself.

@benshi001 @rjmccall
---
 clang/lib/CodeGen/Targets/AVR.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/clang/lib/CodeGen/Targets/AVR.cpp b/clang/lib/CodeGen/Targets/AVR.cpp
index 50547dd6dec5e7d..bc6418c1e224eb4 100644
--- a/clang/lib/CodeGen/Targets/AVR.cpp
+++ b/clang/lib/CodeGen/Targets/AVR.cpp
@@ -112,7 +112,10 @@ class AVRABIInfo : public DefaultABIInfo {
 class AVRTargetCodeGenInfo : public TargetCodeGenInfo {
 public:
   AVRTargetCodeGenInfo(CodeGenTypes &CGT, unsigned NPR, unsigned NRR)
-      : TargetCodeGenInfo(std::make_unique<AVRABIInfo>(CGT, NPR, NRR)) {}
+      : TargetCodeGenInfo(std::make_unique<AVRABIInfo>(CGT, NPR, NRR)) {
+        SwiftInfo =
+          std::make_unique<SwiftABIInfo>(CGT, /*SwiftErrorInRegister=*/true);
+      }
 
   LangAS getGlobalVarAddressSpace(CodeGenModule &CGM,
                                   const VarDecl *D) const override {



More information about the cfe-commits mailing list