-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically register hyperobject struct members in C++
- Loading branch information
1 parent
a5c8b8e
commit cbf8108
Showing
8 changed files
with
57 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,17 @@ | ||
// RUN: %clang_cc1 %s -x c++ -fopencilk -emit-llvm -verify -mllvm -use-opencilk-runtime-bc=false -mllvm -debug-abi-calls -o /dev/null | ||
// expected-no-diagnostics | ||
#define DEPTH 3 | ||
template<int N> 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<N - 1> 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<DEPTH> r; | ||
|
||
int f() { return r.get(DEPTH / 2); } | ||
// expected-note@-1{{in instantiation}} | ||
// expected-note@-2{{in instantiation}} | ||
// expected-note@-3{{in instantiation}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// RUN: %clang_cc1 %s -x c++ -fopencilk -verify -fsyntax-only | ||
struct C { int _Hyperobject c; }; | ||
struct C _Hyperobject c; // expected-error{{type 'struct C', which contains a hyperobject, may not be a hyperobject}} | ||
long _Hyperobject d; // expected-note{{previous definition}} | ||
void f() { | ||
extern int _Hyperobject d; | ||
// expected-error@-1{{redeclaration of 'd' with a different type: 'int _Hyperobject' vs 'long _Hyperobject'}} | ||
} | ||
char _Hyperobject e; // expected-note{{previous definition}} | ||
typedef long _Hyperobject long_h; | ||
void g() { | ||
extern long_h e; // expected-error{{redeclaration of 'e'}} | ||
} | ||
|
||
extern void reduce(void *, void *), identity(void *); | ||
|
||
struct D { | ||
int _Hyperobject(identity, reduce) field; | ||
}; | ||
|
||
int _Hyperobject(reduce, identity) h; | ||
// expected-error@-1{{incompatible function pointer types passing 'void (*)(void *, void *)' to parameter of type 'void (*)(void *)'}} | ||
// expected-error@-2{{incompatible function pointer types passing 'void (*)(void *)' to parameter of type 'void (*)(void *, void *)'}} | ||
|
||
int _Hyperobject(x) i; // expected-error{{use of undeclared identifier 'x'}} | ||
int _Hyperobject(0) j; // expected-error{{hyperobject must have 0 or 2 callbacks}} | ||
int _Hyperobject(0,0,0,0) k; // expected-error{{hyperobject must have 0 or 2 callbacks}} | ||
int _Hyperobject(0, 1) x; // expected-error{{incompatible integer to pointer conversion passing 'int' to parameter of type 'void (*)(void *, void *)'}} | ||
|
||
void function() { | ||
int _Hyperobject(typo1, reduce) var1 = 0; | ||
// expected-error@-1{{use of undeclared identifier 'typo1'}} | ||
int _Hyperobject(typo2, typo3) var2 = 0; | ||
// expected-error@-1{{use of undeclared identifier 'typo2'}} | ||
// expected-error@-2{{use of undeclared identifier 'typo3'}} | ||
int _Hyperobject(0, typo4) var3 = 0; | ||
// expected-error@-1{{use of undeclared identifier 'typo4'}} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters