Skip to content

Commit

Permalink
[SemaExpr] Fix type checking for default-lvalue conversions that invo…
Browse files Browse the repository at this point in the history
…lve hyperobjects.
  • Loading branch information
neboat committed Mar 2, 2024
1 parent f9a7185 commit 3a60e32
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions clang/lib/Sema/SemaExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) {
// converted to a prvalue.
if (!E->isGLValue()) return E;

QualType T = E->getType();
QualType T = E->getType().stripHyperobject();
assert(!T.isNull() && "r-value conversion on typeless expression?");

// lvalue-to-rvalue conversion cannot be applied to function or array types.
Expand Down Expand Up @@ -687,7 +687,7 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) {
CheckForNullPointerDereference(*this, E);

E = BuildHyperobjectLookup(E);
T = E->getType();
assert(T == E->getType() && "Unexpected Type from hyperobject lookup.");

if (const ObjCIsaExpr *OISA = dyn_cast<ObjCIsaExpr>(E->IgnoreParenCasts())) {
NamedDecl *ObjectGetClass = LookupSingleName(TUScope,
Expand Down
15 changes: 15 additions & 0 deletions clang/test/Cilk/hyper-type-delete.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Check that calling delete on a hyperobject produces a useful error message.
//
// RUN: %clang_cc1 %s -xc++ -fopencilk -verify -fsyntax-only
struct S {
int x, y;
};
void identity(void *v);
void reduce(void *l, void *r);
using S_r = S _Hyperobject(identity, reduce);

class Foo {
S_r r; // expected-warning{{reducer callbacks not implemented for structure members}}
public:
~Foo() { delete r; }; // expected-error{{cannot delete expression of type 'S_r' (aka 'S _Hyperobject(identity, reduce)')}}
};

0 comments on commit 3a60e32

Please sign in to comment.