// The test is check we couldn't export a redeclaration which isn't exported previously and
// check it is OK to redeclare no matter exported nor not if is the previous declaration is exported.
// RUN: %clang_cc1 -std=c++20 %s -verify
export module X;
;
typedef S S;
export typedef S S; // OK, does not redeclare an entity
export ; // expected-error {{cannot export redeclaration 'S' here since the previous declaration has module linkage}}
// namespace A
// namespace A
// namespace A
// namespace A
; // expected-note {{previous declaration is here}}
export
; // expected-error {{cannot export redeclaration 'TemplS' here since the previous declaration has module linkage}}
; // expected-note {{previous declaration is here}}
export
; // expected-error {{cannot export redeclaration 'TemplS2' here since the previous declaration has module linkage}}
void ; // expected-note {{previous declaration is here}}
export void ; // expected-error {{cannot export redeclaration 'baz' here since the previous declaration has module linkage}}
// namespace A
// OK
//
// [module.interface]/p6
// A redeclaration of an entity X is implicitly exported if X was introduced by an exported declaration
void ;
// The compiler couldn't export A::f1() here since A::f1() is declared above without exported.
// See [module.interface]/p6 for details.
export void ; // expected-error {{cannot export redeclaration 'f1' here since the previous declaration has module linkage}}
void ; // expected-note {{previous declaration is here}}
export
void
// namespace A
export
void // expected-error {{cannot export redeclaration 'TemplFunc3' here since the previous declaration has module linkage}}
int var; // expected-note {{previous declaration is here}}
export int var; // expected-error {{cannot export redeclaration 'var' here since the previous declaration has module linkage}}
T TemplVar; // expected-note {{previous declaration is here}}
export
T TemplVar; // expected-error {{cannot export redeclaration 'TemplVar' here since the previous declaration has module linkage}}
// Test the compiler wouldn't complain about the redeclaration of friend in exported class.
// namespace Friend