Files
clang-p2996/clang/test/Modules/decldef.mm
Richard Smith 4abe0a8d82 C++ modules: fix a bug where loading a declaration with some name would prevent
name lookup from lazily deserializing the other declarations with the same
name, by tracking a bit to indicate whether a name in a DeclContext might have
additional external results. This also allows lazier reconciling of the lookup
table if a module import adds decls to a pre-existing DC.

However, this exposes a pre-existing bug, which causes a regression in
test/Modules/decldef.mm: if we have a reference to a declaration, and a
later-imported module adds a redeclaration, nothing causes us to load that
redeclaration when we use or emit the reference (which can manifest as a
reference to an undefined inline function, a use of an incomplete type, and so
on). decldef.mm has been extended with an additional testcase which fails with
or without this change.

llvm-svn: 190293
2013-09-09 07:34:56 +00:00

50 lines
1.2 KiB
Plaintext

// RUN: rm -rf %t
// RUN: %clang_cc1 -fmodules -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_EARLY
// RUN: %clang_cc1 -fmodules -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify
// expected-note@Inputs/def.h:5 {{previous}}
@class Def;
Def *def;
class Def2; // expected-note {{forward decl}}
Def2 *def2;
namespace Def3NS { class Def3; } // expected-note {{forward decl}}
Def3NS::Def3 *def3;
@interface Unrelated
- defMethod;
@end
@import decldef;
#ifdef USE_EARLY
A *a1; // expected-error{{declaration of 'A' must be imported from module 'decldef.Def'}}
B *b1;
#endif
@import decldef.Decl;
A *a2;
B *b;
void testA(A *a) {
a->ivar = 17;
#ifndef USE_EARLY
// expected-error@-2{{definition of 'A' must be imported from module 'decldef.Def' before it is required}}
#endif
}
void testB() {
B b; // Note: redundant error silenced
}
void testDef() {
[def defMethod];
}
void testDef2() {
// FIXME: These should both work, since we've (implicitly) imported
// decldef.Def here, but they don't, because nothing has triggered the lazy
// loading of the definitions of these classes.
def2->func(); // expected-error {{incomplete}}
def3->func(); // expected-error {{incomplete}}
}