brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · aa6de44 Raw
64 lines · plain
1// RUN: rm -rf %t2// RUN: split-file %s %t3// RUN: cd %t4//5// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/a.cppm -o %t/a.pcm6// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/b.cppm -o %t/b.pcm7// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %t/c.cpp \8// RUN:     -fprebuilt-module-path=%t9// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %t/d.cpp \10// RUN:     -fprebuilt-module-path=%t11//12// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/h.cppm \13// RUN:     -fprebuilt-module-path=%t -o %t/h.pcm14// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %t/j.cpp \15// RUN:     -fprebuilt-module-path=%t16 17//--- a.cppm18export module a;19export void foo() {20 21}22 23//--- b.cppm24export module b;25void bar();26export void foo() {27    bar();28}29 30//--- c.cpp31// expected-no-diagnostics32// Since we will load all the declaration lazily, we won't be able to find33// the ODR violation here.34import a;35import b;36 37//--- d.cpp38import a;39import b;40// Test that we can still check the odr violation if we call the function41// actually.42void use() {43    foo(); // expected-error@* {{'foo' has different definitions in different modules;}}44           // expected-note@* {{but in 'a' found a different body}}45}46 47// expected-error@a.cppm:* {{declaration 'foo' attached to named module 'a' cannot be attached to other modules}}48// expected-note@b.cppm:* {{}}49 50//--- h.cppm51export module h;52export import a;53export import b;54 55//--- j.cpp56import h;57void use() {58    foo(); // expected-error@* {{'foo' has different definitions in different modules;}}59           // expected-note@* {{but in 'a' found a different body}}60}61 62// expected-error@a.cppm:* {{declaration 'foo' attached to named module 'a' cannot be attached to other modules}}63// expected-note@b.cppm:* {{}}64