brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.8 KiB · f8a763a Raw
184 lines · plain
1// RUN: rm -rf %t2// RUN: mkdir %t3// RUN: split-file %s %t4//5// RUN: %clang_cc1 -std=c++20 -emit-module-interface -I%t %t/A.cppm -o %t/A.pcm6// RUN: %clang_cc1 -std=c++20 -emit-module-interface -I%t %t/B.cppm -o %t/B.pcm7// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -verify -fsyntax-only8// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use2.cpp -verify -fsyntax-only9// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use3.cpp -verify -fsyntax-only10// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use4.cpp -verify -fsyntax-only11// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/C.cppm -verify -fsyntax-only12// RUN: %clang_cc1 -std=c++20 -I%t %t/D.cppm -verify -fsyntax-only13// RUN: %clang_cc1 -std=c++20 -I%t %t/E.cppm -verify -fsyntax-only14// RUN: %clang_cc1 -std=c++20 -I%t %t/F.cppm -verify -fsyntax-only15//16// Testing header units for coverity.17// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/foo.h -o %t/foo.pcm18// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -fmodule-file=%t/foo.pcm %t/Use5.cpp -verify -fsyntax-only19// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -fmodule-file=%t/foo.pcm %t/Use6.cpp -verify -fsyntax-only20//21// Testing with module map modules. It is unclear about the relation ship between Clang modules and22// C++20 Named Modules. Will they coexist? Or will they be mutually exclusive?23// The test here is for primarily coverity.24//25// RUN: rm -f %t/foo.pcm26// RUN: %clang_cc1 -std=c++20 -fmodules -fmodules-cache-path=%t -fprebuilt-module-path=%t \27// RUN:   -fmodule-map-file=%t/module.modulemap %t/Use7.cpp -verify -fsyntax-only28// RUN: %clang_cc1 -std=c++20 -fmodules -fmodules-cache-path=%t -fprebuilt-module-path=%t \29// RUN:   -fmodule-map-file=%t/module.modulemap %t/Use7.cpp -verify -fsyntax-only30// Testing module map modules with named modules.31// RUN: %clang_cc1 -std=c++20 -fmodules -fmodules-cache-path=%t -fmodule-map-file=%t/module.modulemap \32// RUN:   %t/A.cppm -o %t/A.pcm33// RUN: %clang_cc1 -std=c++20 -fmodules -fmodules-cache-path=%t -fprebuilt-module-path=%t \34// RUN:   -fmodule-map-file=%t/module.modulemap %t/Use7.cpp -verify -fsyntax-only35// RUN: %clang_cc1 -std=c++20 -fmodules -fmodules-cache-path=%t -fprebuilt-module-path=%t \36// RUN:   -fmodule-map-file=%t/module.modulemap %t/Use7.cpp -verify -fsyntax-only37 38//39//--- foo.h40#ifndef FOO_H41#define FOO_H42template <class T, class U>43concept same_as = __is_same(T, U);44#endif45 46// The compiler would warn if we include foo_h twice without guard.47//--- redecl.h48#ifndef REDECL_H49#define REDECL_H50template <class T, class U>51concept same_as = __is_same(T, U);52#endif53 54//--- A.cppm55module;56#include "foo.h"57export module A;58export using ::same_as;59 60//--- B.cppm61module;62#include "foo.h"63export module B;64export using ::same_as;65 66//--- Use.cpp67// expected-no-diagnostics68import A;69import B;70 71template <class T> void foo()72  requires same_as<T, int>73{}74 75//--- Use2.cpp76// expected-no-diagnostics77#include "foo.h"78import A;79 80template <class T> void foo()81  requires same_as<T, int>82{}83 84//--- Use3.cpp85// expected-no-diagnostics86import A;87#include "foo.h"88 89template <class T> void foo()90  requires same_as<T, int>91{}92 93//--- Use4.cpp94// expected-no-diagnostics95import A;96import B;97#include "foo.h"98 99template <class T> void foo()100  requires same_as<T, int>101{}102 103//--- C.cppm104// expected-no-diagnostics105module;106#include "foo.h"107export module C;108import A;109import B;110 111template <class T> void foo()112  requires same_as<T, int>113{}114 115//--- D.cppm116module;117#include "foo.h"118#include "redecl.h"119export module D;120export using ::same_as;121 122// expected-error@* {{redefinition of 'same_as'}}123// expected-note@* 1+{{previous definition is here}}124 125//--- E.cppm126module;127#include "foo.h"128export module E;129export template <class T, class U>130concept same_as = __is_same(T, U);131 132// expected-error@* {{redefinition of 'same_as'}}133// expected-note@* 1+{{previous definition is here}}134 135//--- F.cppm136export module F;137template <class T, class U>138concept same_as = __is_same(T, U);139template <class T, class U>140concept same_as = __is_same(T, U);141 142// expected-error@* {{redefinition of 'same_as'}}143// expected-note@* 1+{{previous definition is here}}144 145//--- Use5.cpp146import "foo.h";  // expected-warning {{the implementation of header units is in an experimental phase}}147import A;148 149template <class T> void foo()150  requires same_as<T, int>151{}152 153//--- Use6.cpp154import A;155import "foo.h"; // expected-warning {{the implementation of header units is in an experimental phase}}156 157template <class T> void foo()158  requires same_as<T, int>159{}160 161//--- module.modulemap162module "foo" {163  export * 164  header "foo.h"165}166 167//--- Use7.cpp168// expected-no-diagnostics169#include "foo.h"170import A;171 172template <class T> void foo()173  requires same_as<T, int>174{}175 176//--- Use8.cpp177// expected-no-diagnostics178import A;179#include "foo.h"180 181template <class T> void foo()182  requires same_as<T, int>183{}184