Skip to content

Commit 14099cb

Browse files
committed
[CHERIoT] Allow extern on cheriot_sealed global variables
1 parent e69c5d7 commit 14099cb

File tree

3 files changed

+2
-20
lines changed

3 files changed

+2
-20
lines changed

clang/lib/Sema/SemaDecl.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14948,24 +14948,6 @@ Sema::DeclGroupPtrTy Sema::FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS,
1494814948
if (!D)
1494914949
continue;
1495014950

14951-
auto *VD = dyn_cast<VarDecl>(D);
14952-
14953-
/// CHERIoT-specific check. If a variable is declared with a sealed type, it
14954-
/// can't have external storage, since its initializer must be available in
14955-
/// the unit.
14956-
///
14957-
/// For example
14958-
/// ```
14959-
/// typedef int MySealedType __attribute__((cheriot_sealed("MyCompartment",
14960-
/// "MySealingKeyType"))); extern MySealedType mySealedObject;
14961-
/// ```
14962-
/// would not really make sense.
14963-
if (VD && VD->getType().hasCHERIoTSealedAttr() &&
14964-
VD->hasExternalStorage()) {
14965-
Diag(D->getLocation(), diag::err_cheriot_invalid_sealed_declaration)
14966-
<< "external";
14967-
}
14968-
1496914951
// Check if the Decl has been declared in '#pragma omp declare target'
1497014952
// directive and has static storage duration.
1497114953
if (auto *VD = dyn_cast<VarDecl>(D);

clang/test/Sema/cheri/cheriot-static-sealed-value-attr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ MyObj4 Obj4 = {0, 0, 0, 0};
1818

1919
struct PlainObj plainObj = {10};
2020
MyObj5 Obj5 = &plainObj;
21-
extern MyObj5 Obj6; // expected-error{{cannot declare a sealed variable as external}}
21+
extern MyObj5 Obj6; // No warnings here, it is allowed to declare it `extern`.
2222

2323
void useStruct(struct MyObj x);
2424
void useStructSealedCap(struct MyObj *__sealed_capability x);

clang/test/SemaCXX/cheri/cheriot-static-sealed-value-attr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ MyObj4 Obj4 = {0, 0, 0, 0};
1717

1818
struct PlainObj plainObj = {10};
1919
MyObj5 Obj5 = &plainObj;
20-
extern MyObj5 Obj6; // expected-error{{cannot declare a sealed variable as external}}
20+
extern MyObj5 Obj6; // No warnings here, it is allowed to declare it `extern`.
2121

2222
void useStruct(struct MyObj x);
2323
void useStructSealedCap(struct MyObj *__sealed_capability x);

0 commit comments

Comments
 (0)