diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index 1a4e5a790d00..a7a76af91ab7 100644 --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/lib/AST/DeclCXX.cpp @@ -1072,6 +1072,9 @@ void CXXRecordDecl::addedMember(Decl *D) { } if (T->isHyperobjectType()) { + // Do not allow braced list initialization, which would + // suppress hyperobject registration. + data().Aggregate = false; data().HasIrrelevantDestructor = false; data().HasTrivialSpecialMembers &= ~SMF_Destructor; data().HasTrivialSpecialMembersForCall &= ~SMF_Destructor; diff --git a/clang/test/Cilk/hyper-init-error.cpp b/clang/test/Cilk/hyper-init-error.cpp new file mode 100644 index 000000000000..38c608c85bf5 --- /dev/null +++ b/clang/test/Cilk/hyper-init-error.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 %s -fopencilk -verify -fsyntax-only +extern void id(void *), reduce(void *, void *); +struct one_hyperobject { + // expected-note@-1{{implicit copy}} + // expected-note@-2{{implicit move}} + // expected-note@-3{{implicit default}} + int _Hyperobject(id, reduce) field; +}; + +// braced initializer lists do not work +one_hyperobject h1 = {-1}; +// expected-error@-1{{no matching constructor for initialization}} + +one_hyperobject h2;