2017-09-04 13:37:53 +08:00
|
|
|
// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -o %t.0.pcm -verify -DTEST=0
|
|
|
|
// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -o %t.1.pcm -verify -DTEST=1
|
|
|
|
// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -fmodule-file=%t.0.pcm -o %t.2.pcm -verify -DTEST=2
|
|
|
|
// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -fmodule-file=%t.0.pcm -o %t.3.pcm -verify -Dfoo=bar -DTEST=3
|
2016-09-09 07:14:54 +08:00
|
|
|
|
|
|
|
#if TEST == 0
|
|
|
|
// expected-no-diagnostics
|
|
|
|
#endif
|
|
|
|
|
2017-04-22 06:39:18 +08:00
|
|
|
export module foo;
|
2017-04-25 07:12:30 +08:00
|
|
|
#if TEST == 2
|
|
|
|
// expected-error@-2 {{redefinition of module 'foo'}}
|
|
|
|
// expected-note@modules-ts.cppm:* {{loaded from}}
|
2016-09-09 07:14:54 +08:00
|
|
|
#endif
|
|
|
|
|
2017-07-05 09:42:07 +08:00
|
|
|
static int m;
|
2017-10-10 07:42:09 +08:00
|
|
|
#if TEST == 2
|
2017-07-05 09:42:07 +08:00
|
|
|
// expected-error@-2 {{redefinition of '}}
|
|
|
|
// expected-note@-3 {{unguarded header; consider using #ifdef guards or #pragma once}}
|
|
|
|
// FIXME: We should drop the "header from" in this diagnostic.
|
|
|
|
// expected-note-re@modules-ts.cppm:1 {{'{{.*}}modules-ts.cppm' included multiple times, additional include site in header from module 'foo'}}
|
|
|
|
#endif
|
2016-09-09 07:14:54 +08:00
|
|
|
int n;
|
2017-09-04 13:37:53 +08:00
|
|
|
#if TEST == 2
|
2016-09-09 07:14:54 +08:00
|
|
|
// expected-error@-2 {{redefinition of '}}
|
2017-05-11 14:20:07 +08:00
|
|
|
// expected-note@-3 {{unguarded header; consider using #ifdef guards or #pragma once}}
|
2017-05-18 10:29:20 +08:00
|
|
|
// FIXME: We should drop the "header from" in this diagnostic.
|
|
|
|
// expected-note-re@modules-ts.cppm:1 {{'{{.*}}modules-ts.cppm' included multiple times, additional include site in header from module 'foo'}}
|
2016-09-09 07:14:54 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if TEST == 0
|
|
|
|
export {
|
|
|
|
int a;
|
|
|
|
int b;
|
|
|
|
constexpr int *p = &n;
|
|
|
|
}
|
|
|
|
export int c;
|
|
|
|
|
|
|
|
namespace N {
|
|
|
|
export void f() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
export struct T {} t;
|
|
|
|
#elif TEST == 3
|
|
|
|
int use_a = a; // expected-error {{declaration of 'a' must be imported from module 'foo' before it is required}}
|
|
|
|
// expected-note@-13 {{previous}}
|
|
|
|
|
|
|
|
#undef foo
|
|
|
|
import foo;
|
|
|
|
|
|
|
|
export {} // expected-error {{export declaration cannot be empty}}
|
|
|
|
export { ; }
|
|
|
|
export { static_assert(true); }
|
|
|
|
|
|
|
|
// FIXME: These diagnostics are not very good.
|
|
|
|
export import foo; // expected-error {{expected unqualified-id}}
|
|
|
|
export { import foo; } // expected-error {{expected unqualified-id}}
|
|
|
|
|
|
|
|
int use_b = b;
|
|
|
|
int use_n = n; // FIXME: this should not be visible, because it is not exported
|
|
|
|
|
|
|
|
extern int n;
|
2017-09-04 13:37:53 +08:00
|
|
|
static_assert(&n != p);
|
2016-09-09 07:14:54 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if TEST == 1
|
|
|
|
struct S {
|
|
|
|
export int n; // expected-error {{expected member name or ';'}}
|
|
|
|
export static int n; // expected-error {{expected member name or ';'}}
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// FIXME: Exports of declarations without external linkage are disallowed.
|
|
|
|
// Exports of declarations with non-external-linkage types are disallowed.
|
2016-09-27 05:27:23 +08:00
|
|
|
|
|
|
|
// Cannot export within another export. This isn't precisely covered by the
|
|
|
|
// language rules right now, but (per personal correspondence between zygoloid
|
|
|
|
// and gdr) is the intent.
|
|
|
|
#if TEST == 1
|
|
|
|
export {
|
|
|
|
extern "C++" {
|
|
|
|
namespace NestedExport {
|
|
|
|
export { // expected-error {{appears within another export}}
|
|
|
|
int q;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|