63 lines · plain
1// RUN: rm -rf %t2// RUN: mkdir -p %t3// RUN: split-file %s %t4//5// Baseline testing to make sure we can detect the ODR violation from the CC1 invocation.6// RUNX: %clang_cc1 -std=c++20 %t/a.cppm -emit-module-interface -o %t/a.pcm7// RUNX: %clang_cc1 -std=c++20 %t/b.cppm -emit-module-interface -o %t/b.pcm8// RUNX: %clang_cc1 -std=c++20 %t/test.cc -fprebuilt-module-path=%t -fsyntax-only -verify9//10// Testing that we can ignore the ODR violation from the driver invocation.11// RUN: %clang -std=c++20 %t/a.cppm --precompile -o %t/a.pcm12// RUN: %clang -std=c++20 %t/b.cppm --precompile -o %t/b.pcm13// RUN: %clang -std=c++20 %t/test.cc -fprebuilt-module-path=%t -fsyntax-only -Xclang -verify \14// RUN: -DIGNORE_ODR_VIOLATION15//16// Testing that the driver can require to check the ODR violation.17// RUN: %clang -std=c++20 -Xclang -fno-skip-odr-check-in-gmf %t/a.cppm --precompile -o %t/a.pcm18// RUN: %clang -std=c++20 -Xclang -fno-skip-odr-check-in-gmf %t/b.cppm --precompile -o %t/b.pcm19// RUN: %clang -std=c++20 -Xclang -fno-skip-odr-check-in-gmf %t/test.cc -fprebuilt-module-path=%t \20// RUN: -fsyntax-only -Xclang -verify21 22//--- func1.h23bool func(int x, int y) {24 return true;25}26 27//--- func2.h28bool func(int x, int y) {29 return false;30}31 32//--- a.cppm33module;34#include "func1.h"35export module a;36export using ::func;37 38export extern "C++" bool func1() { return true; }39 40//--- b.cppm41module;42#include "func2.h"43export module b;44export using ::func;45 46export extern "C++" bool func1() { return false; }47 48//--- test.cc49import a;50import b;51bool test() {52 return func(1, 2) && func1();53}54 55#ifdef IGNORE_ODR_VIOLATION56// expected-no-diagnostics57#else58// expected-error@func2.h:1 {{'func' has different definitions in different modules;}}59// expected-note@func1.h:1 {{but in 'a.<global>' found a different body}}60// expected-error@b.cppm:6 {{'func1' has different definitions in different modules; definition in module 'b.<implicit global>' first difference is function body}}61// expected-note@a.cppm:6 {{but in 'a.<implicit global>' found a different body}}62#endif63