Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14948,24 +14948,6 @@ Sema::DeclGroupPtrTy Sema::FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS,
if (!D)
continue;

auto *VD = dyn_cast<VarDecl>(D);

/// CHERIoT-specific check. If a variable is declared with a sealed type, it
/// can't have external storage, since its initializer must be available in
/// the unit.
///
/// For example
/// ```
/// typedef int MySealedType __attribute__((cheriot_sealed("MyCompartment",
/// "MySealingKeyType"))); extern MySealedType mySealedObject;
/// ```
/// would not really make sense.
if (VD && VD->getType().hasCHERIoTSealedAttr() &&
VD->hasExternalStorage()) {
Diag(D->getLocation(), diag::err_cheriot_invalid_sealed_declaration)
<< "external";
}

// Check if the Decl has been declared in '#pragma omp declare target'
// directive and has static storage duration.
if (auto *VD = dyn_cast<VarDecl>(D);
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Sema/cheri/cheriot-static-sealed-value-attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ MyObj4 Obj4 = {0, 0, 0, 0};

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

void useStruct(struct MyObj x);
void useStructSealedCap(struct MyObj *__sealed_capability x);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ MyObj4 Obj4 = {0, 0, 0, 0};

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

void useStruct(struct MyObj x);
void useStructSealedCap(struct MyObj *__sealed_capability x);
Expand Down