mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-28 17:56:06 +00:00

variable from being the function to being the enclosing namespace scope (in C++) or the TU (in C). This allows us to fix a selection of related issues where we would build incorrect redeclaration chains for such declarations, and fail to notice type mismatches. Such declarations are put into a new IdentifierNamespace, IDNS_LocalExtern, which is only found when searching scopes, and not found when searching DeclContexts. Such a declaration is only made visible in its DeclContext if there are no non-LocalExtern declarations. llvm-svn: 191064
74 lines
1.5 KiB
C++
74 lines
1.5 KiB
C++
// RUN: %clang_cc1 -fsyntax-only -verify %s -fblocks -std=c++1y
|
|
|
|
extern "C" int exit(int);
|
|
|
|
typedef struct {
|
|
unsigned long ps[30];
|
|
int qs[30];
|
|
} BobTheStruct;
|
|
|
|
int main (int argc, const char * argv[]) {
|
|
BobTheStruct inny;
|
|
BobTheStruct outty;
|
|
BobTheStruct (^copyStruct)(BobTheStruct);
|
|
int i;
|
|
|
|
for(i=0; i<30; i++) {
|
|
inny.ps[i] = i * i * i;
|
|
inny.qs[i] = -i * i * i;
|
|
}
|
|
|
|
copyStruct = ^(BobTheStruct aBigStruct){ return aBigStruct; }; // pass-by-value intrinsically copies the argument
|
|
|
|
outty = copyStruct(inny);
|
|
|
|
if ( &inny == &outty ) {
|
|
exit(1);
|
|
}
|
|
for(i=0; i<30; i++) {
|
|
if ( (inny.ps[i] != outty.ps[i]) || (inny.qs[i] != outty.qs[i]) ) {
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
namespace rdar8134521 {
|
|
void foo() {
|
|
int (^P)(int) = reinterpret_cast<int(^)(int)>(1);
|
|
P = (int(^)(int))(1);
|
|
|
|
P = reinterpret_cast<int(^)(int)>((void*)1);
|
|
P = (int(^)(int))((void*)1);
|
|
}
|
|
}
|
|
|
|
namespace rdar11055105 {
|
|
struct A {
|
|
void foo();
|
|
};
|
|
|
|
template <class T> void foo(T &x) noexcept(noexcept(x.foo()));
|
|
|
|
void (^block)() = ^{
|
|
A a;
|
|
foo(a);
|
|
};
|
|
}
|
|
|
|
namespace LocalDecls {
|
|
void f() {
|
|
(void) ^{
|
|
extern int a; // expected-note {{previous}}
|
|
extern int b(); // expected-note {{previous}}
|
|
};
|
|
}
|
|
void g() {
|
|
(void) ^{
|
|
extern float a; // expected-error {{different type}}
|
|
extern float b(); // expected-error {{cannot be overloaded}}
|
|
};
|
|
}
|
|
}
|