diff options
| author | Zahira Ammarguellat <zahira.ammarguellat@intel.com> | 2022-02-02 11:28:44 -0800 |
|---|---|---|
| committer | Zahira Ammarguellat <zahira.ammarguellat@intel.com> | 2022-02-02 13:12:33 -0800 |
| commit | e692654a4dc017b0bddc4366b328dd6d68d2740a (patch) | |
| tree | 37a562717e9c75c9d268a81ac1d9f863b3126448 | |
| parent | be9946b877add0db906090d22840b213c3f41dd2 (diff) | |
| download | llvm-e692654a4dc017b0bddc4366b328dd6d68d2740a.zip llvm-e692654a4dc017b0bddc4366b328dd6d68d2740a.tar.gz llvm-e692654a4dc017b0bddc4366b328dd6d68d2740a.tar.bz2 | |
The methods visited for a special class must have an identifier.
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 2 | ||||
| -rw-r--r-- | clang/test/SemaSYCL/special-class-attribute.cpp | 16 |
2 files changed, 17 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index cbd9df4..a86947a 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -9193,7 +9193,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, } if ((Parent->isClass() || Parent->isStruct()) && Parent->hasAttr<SYCLSpecialClassAttr>() && - NewFD->getKind() == Decl::Kind::CXXMethod && + NewFD->getKind() == Decl::Kind::CXXMethod && NewFD->getIdentifier() && NewFD->getName() == "__init" && D.isFunctionDefinition()) { if (auto *Def = Parent->getDefinition()) Def->setInitMethod(true); diff --git a/clang/test/SemaSYCL/special-class-attribute.cpp b/clang/test/SemaSYCL/special-class-attribute.cpp index f06a7b1..1bfe7cc 100644 --- a/clang/test/SemaSYCL/special-class-attribute.cpp +++ b/clang/test/SemaSYCL/special-class-attribute.cpp @@ -30,6 +30,14 @@ class class5 { void __init(){} }; +struct __attribute__((sycl_special_class)) struct6 { + struct6(); + bool operator==(const struct6 &); + struct6 &operator()(); + ~struct6(); + void __init(){} +}; + // Must have one and only one __init method defined class __attribute__((sycl_special_class)) class6 { // expected-error {{types with 'sycl_special_class' attribute must have one and only one '__init' method defined}} class6() {} @@ -47,6 +55,14 @@ class [[clang::sycl_special_class]] class8 { // expected-error {{types with 'syc struct __attribute__((sycl_special_class)) struct3; struct struct3 {}; // expected-error {{types with 'sycl_special_class' attribute must have one and only one '__init' method defined}} +// expected-error@+1{{'sycl_special_class' attribute must have one and only one '__init' method defined}} +struct __attribute__((sycl_special_class)) struct7 { + struct7(); + bool operator==(const struct7 &); + struct7 &operator()(); + ~struct7(); +}; + // Only classes [[clang::sycl_special_class]] int var1 = 0; // expected-warning {{'sycl_special_class' attribute only applies to classes}} __attribute__((sycl_special_class)) int var2 = 0; // expected-warning {{'sycl_special_class' attribute only applies to classes}} |
