57 lines · cpp
1// RUN: split-file %s %t2 3// RUN: %clang_cc1 -std=c++14 -x c++ -fmodules -fmodule-name=A -emit-module %t/a.modulemap -o %t/a.pcm4// RUN: %clang_cc1 -std=c++14 -x c++ -fmodules -fmodule-name=B -emit-module %t/b.modulemap -o %t/b.pcm5// RUN: %clang_cc1 -std=c++14 -x c++ -fmodules -fmodule-map-file=%t/a.modulemap -fmodule-map-file=%t/b.modulemap \6// RUN: -fmodule-file=%t/a.pcm -fmodule-file=%t/b.pcm \7// RUN: %t/use.cc -verify8 9// RUN: rm -f %t/*.pcm10 11// RUN: %clang_cc1 -std=c++14 -x c++ -fmodules -fmodule-name=A -emit-module %t/a.modulemap -o %t/a.pcm -triple i686-windows12// RUN: %clang_cc1 -std=c++14 -x c++ -fmodules -fmodule-name=B -emit-module %t/b.modulemap -o %t/b.pcm -triple i686-windows13// RUN: %clang_cc1 -std=c++14 -x c++ -fmodules -fmodule-map-file=%t/a.modulemap -fmodule-map-file=%t/b.modulemap \14// RUN: -fmodule-file=%t/a.pcm -fmodule-file=%t/b.pcm \15// RUN: %t/use.cc -verify -triple i686-windows16 17//--- a.modulemap18module A {19 header "a.h"20}21 22//--- a.h23#ifndef A_H24#define A_H25template<typename T> struct ct { friend auto operator-(ct, ct) { struct X {}; return X(); } void x(); };26#endif27 28//--- b.modulemap29module B {30 header "b.h"31}32 33//--- b.h34#ifndef B_H35#define B_H36template<typename T> struct ct { friend auto operator-(ct, ct) { struct X {}; return X(); } void x(); };37inline auto f() { return ct<float>() - ct<float>(); }38#endif39 40//--- use.cc41// expected-no-diagnostics42// Force the definition of ct in module A to be the primary definition.43#include "a.h"44template<typename T> void ct<T>::x() {}45 46// Attempt to cause the definition of operator- in the ct primary template in47// module B to be the primary definition of that function. If that happens,48// we'll be left with a class template ct that appears to not contain a49// definition of the inline friend function.50#include "b.h"51auto v = f();52 53ct<int> make();54void h() {55 make() - make();56}57