From aee817f154a3c6b0dbb45a386f31591c0c62a5f6 Mon Sep 17 00:00:00 2001 From: "John F. Carr" Date: Wed, 13 Dec 2023 13:27:19 -0500 Subject: [PATCH] HyperobjectType needs to copy dependence flags from parameters --- clang/lib/AST/Type.cpp | 3 +++ clang/test/Cilk/222.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 clang/test/Cilk/222.cpp diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index d32e47372e40..00e0738c536b 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -3208,6 +3208,9 @@ HyperobjectType::HyperobjectType(QualType Element, QualType CanonicalPtr, IdentityID(ifn), ReduceID(rfn) { if (Element->isIncompleteType()) // diagnosed in caller addDependence(TypeDependence::Error); + addDependence(Element->getDependence()); + addDependence(toTypeDependence(i->getDependence())); + addDependence(toTypeDependence(r->getDependence())); } bool HyperobjectType::hasCallbacks() const { diff --git a/clang/test/Cilk/222.cpp b/clang/test/Cilk/222.cpp new file mode 100644 index 000000000000..8184b3e11f22 --- /dev/null +++ b/clang/test/Cilk/222.cpp @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 %s -x c++ -fopencilk -emit-llvm -verify -mllvm -use-opencilk-runtime-bc=false -mllvm -debug-abi-calls -o /dev/null +#define DEPTH 3 +template struct R { + static void identity(void *); + static void reduce(void *, void *); + int get(int depth) { return depth <= 0 ? i : field.get(depth - 1); } +public: + R field; + // expected-note@-1{{in instantiation}} + // expected-note@-2{{in instantiation}} + // expected-note@-3{{in instantiation}} + int _Hyperobject(identity, reduce) i; + // expected-warning@-1{{reducer callbacks not implemented for structure members}} + // expected-warning@-2{{reducer callbacks not implemented for structure members}} + // expected-warning@-3{{reducer callbacks not implemented for structure members}} +}; + +template<> struct R<0> { int field; int get(int) { return field; } }; + +extern R r; + +int f() { return r.get(DEPTH / 2); } +// expected-note@-1{{in instantiation}} +// expected-note@-2{{in instantiation}} +// expected-note@-3{{in instantiation}} +