Skip to content

Commit 77a592b

Browse files
committed
[CHERIoT] Relax libcall-export-from-compartment warnings when the export is weak.
This is needed to unblock updating to a newer libc++ in CheriotRTOS.
1 parent b515057 commit 77a592b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

clang/lib/Sema/SemaDecl.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15902,13 +15902,14 @@ Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D,
1590215902
Diag(FD->getLocation(), diag::warn_function_def_in_objc_container);
1590315903

1590415904
if (FD->getType()->getAs<FunctionType>()->getCallConv() == CC_CHERILibCall &&
15905-
!Context.getLangOpts().CheriCompartmentName.empty())
15905+
!Context.getLangOpts().CheriCompartmentName.empty() && !FD->isInlined())
1590615906
Diag(FD->getLocation(),
1590715907
diag::err_cheri_libcall_implemented_wrong_compartment)
1590815908
<< Context.getLangOpts().CheriCompartmentName;
1590915909
else if (FD->hasAttr<CHERICompartmentNameAttr>() &&
1591015910
(FD->getAttr<CHERICompartmentNameAttr>()->getCompartmentName() !=
15911-
Context.getLangOpts().CheriCompartmentName))
15911+
Context.getLangOpts().CheriCompartmentName) &&
15912+
!FD->isInlined())
1591215913
Diag(FD->getLocation(), diag::err_cheri_implemented_wrong_compartment)
1591315914
<< FD->getAttr<CHERICompartmentNameAttr>()->getCompartmentName()
1591415915
<< Context.getLangOpts().CheriCompartmentName;

clang/test/Sema/cheri/cheri-mcu-compartment-warns.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,9 @@ int shouldBePrototype(void) // libcall-error{{CHERI compartment entry declared f
1212
{
1313
return 1;
1414
}
15+
16+
__attribute__((cheriot_libcall))
17+
inline int inlineDefinition(int a, int b)
18+
{
19+
return a+b;
20+
}

0 commit comments

Comments
 (0)