brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · f915649 Raw
84 lines · plain
1// RUN: rm -rf %t2// RUN: mkdir %t3// RUN: split-file %s %t4//5// RUN: %clang_cc1 -std=c++20 %t/m1.cppm -emit-module-interface -o %t/m1.pcm6// RUN: %clang_cc1 -std=c++20 %t/m2.cppm -emit-module-interface -o %t/m2.pcm7// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/use.cc -fsyntax-only \8// RUN:     -verify9//10// RUN: %clang_cc1 -std=c++20 %t/m1.cppm -Wall -emit-module-interface -o %t/m1.pcm11// RUN: %clang_cc1 -std=c++20 %t/m2.cppm -Wall -emit-module-interface -o %t/m2.pcm12// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/use.cc -fsyntax-only \13// RUN:     -verify -Wall14//15// RUN: %clang_cc1 -std=c++20 %t/m1.cppm -Wdecls-in-multiple-modules -emit-module-interface -o %t/m1.pcm16// RUN: %clang_cc1 -std=c++20 %t/m2.cppm -Wdecls-in-multiple-modules -emit-module-interface -o %t/m2.pcm17// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/use.cc -fsyntax-only \18// RUN:     -verify -Wdecls-in-multiple-modules -DWARNING19 20//--- foo.h21#ifndef FOO_H22#define FOO_H23 24enum E { E1, E2 };25 26int a = 43;27 28class foo {29public:30    void consume(E, int);31};32 33inline void func() {}34 35void fwd_decl();36 37#endif 38 39//--- m1.cppm40module;41#include "foo.h"42export module m1;43export {44    using ::foo;45    using ::a;46    using ::func;47    using ::fwd_decl;48    using ::E;49}50 51//--- m2.cppm52module;53#include "foo.h"54export module m2;55export {56    using ::foo;57    using ::a;58    using ::func;59    using ::fwd_decl;60    using ::E;61}62 63//--- use.cc64import m1;65import m2;66void use();67void use() {68    E e = E1;69    foo f;70    f.consume(e, a);71    func();72    fwd_decl();73}74 75#ifndef WARNING76// expected-no-diagnostics77#else78// expected-warning@* {{declaration 'E' is detected to be defined in multiple module units}}79// expected-warning@* {{declaration 'foo' is detected to be defined in multiple module units}}80// expected-warning@* {{declaration 'a' is detected to be defined in multiple module units}}81// expected-warning@* {{declaration 'func' is detected to be defined in multiple module units}}82// expected-note@* 1+ {{}}83#endif84