From a5469584f61abeec98ff89347294f9ed72eca280 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Mon, 4 Jan 2021 07:45:36 -0800 Subject: [PATCH] c++: Add stdlib module test cases The remaining modules tests use the std library. These are those. gcc/testsuite/ * g++.dg/modules/binding-1_a.H: New. * g++.dg/modules/binding-1_b.H: New. * g++.dg/modules/binding-1_c.C: New. * g++.dg/modules/binding-2.H: New. * g++.dg/modules/builtin-3_a.C: New. * g++.dg/modules/global-2_a.C: New. * g++.dg/modules/global-2_b.C: New. * g++.dg/modules/global-3_a.C: New. * g++.dg/modules/global-3_b.C: New. * g++.dg/modules/hello-1_a.C: New. * g++.dg/modules/hello-1_b.C: New. * g++.dg/modules/iostream-1_a.H: New. * g++.dg/modules/iostream-1_b.C: New. * g++.dg/modules/part-5_a.C: New. * g++.dg/modules/part-5_b.C: New. * g++.dg/modules/part-5_c.C: New. * g++.dg/modules/stdio-1_a.H: New. * g++.dg/modules/stdio-1_b.C: New. * g++.dg/modules/string-1_a.H: New. * g++.dg/modules/string-1_b.C: New. * g++.dg/modules/string-view1.C: New. * g++.dg/modules/string-view2.C: New. * g++.dg/modules/tinfo-1.C: New. * g++.dg/modules/tinfo-2_a.H: New. * g++.dg/modules/tinfo-2_b.C: New. * g++.dg/modules/tname-spec-1_a.H: New. * g++.dg/modules/tname-spec-1_b.C: New. * g++.dg/modules/xtreme-header-1.h: New. * g++.dg/modules/xtreme-header-1_a.H: New. * g++.dg/modules/xtreme-header-1_b.C: New. * g++.dg/modules/xtreme-header-1_c.C: New. * g++.dg/modules/xtreme-header-2.h: New. * g++.dg/modules/xtreme-header-2_a.H: New. * g++.dg/modules/xtreme-header-2_b.C: New. * g++.dg/modules/xtreme-header-2_c.C: New. * g++.dg/modules/xtreme-header-3.h: New. * g++.dg/modules/xtreme-header-3_a.H: New. * g++.dg/modules/xtreme-header-3_b.C: New. * g++.dg/modules/xtreme-header-3_c.C: New. * g++.dg/modules/xtreme-header-4.h: New. * g++.dg/modules/xtreme-header-4_a.H: New. * g++.dg/modules/xtreme-header-4_b.C: New. * g++.dg/modules/xtreme-header-4_c.C: New. * g++.dg/modules/xtreme-header-5.h: New. * g++.dg/modules/xtreme-header-5_a.H: New. * g++.dg/modules/xtreme-header-5_b.C: New. * g++.dg/modules/xtreme-header-5_c.C: New. * g++.dg/modules/xtreme-header-6.h: New. * g++.dg/modules/xtreme-header-6_a.H: New. * g++.dg/modules/xtreme-header-6_b.C: New. * g++.dg/modules/xtreme-header-6_c.C: New. * g++.dg/modules/xtreme-header.h: New. * g++.dg/modules/xtreme-header_a.H: New. * g++.dg/modules/xtreme-header_b.C: New. * g++.dg/modules/xtreme-tr1.h: New. * g++.dg/modules/xtreme-tr1_a.H: New. * g++.dg/modules/xtreme-tr1_b.C: New. --- gcc/testsuite/g++.dg/modules/binding-1_a.H | 4 + gcc/testsuite/g++.dg/modules/binding-1_b.H | 4 + gcc/testsuite/g++.dg/modules/binding-1_c.C | 7 + gcc/testsuite/g++.dg/modules/binding-2.H | 9 ++ gcc/testsuite/g++.dg/modules/builtin-3_a.C | 44 ++++++ gcc/testsuite/g++.dg/modules/global-2_a.C | 22 +++ gcc/testsuite/g++.dg/modules/global-2_b.C | 10 ++ gcc/testsuite/g++.dg/modules/global-3_a.C | 16 ++ gcc/testsuite/g++.dg/modules/global-3_b.C | 9 ++ gcc/testsuite/g++.dg/modules/hello-1_a.C | 12 ++ gcc/testsuite/g++.dg/modules/hello-1_b.C | 9 ++ gcc/testsuite/g++.dg/modules/iostream-1_a.H | 10 ++ gcc/testsuite/g++.dg/modules/iostream-1_b.C | 9 ++ gcc/testsuite/g++.dg/modules/part-5_a.C | 13 ++ gcc/testsuite/g++.dg/modules/part-5_b.C | 6 + gcc/testsuite/g++.dg/modules/part-5_c.C | 10 ++ gcc/testsuite/g++.dg/modules/stdio-1_a.H | 14 ++ gcc/testsuite/g++.dg/modules/stdio-1_b.C | 14 ++ gcc/testsuite/g++.dg/modules/string-1_a.H | 4 + gcc/testsuite/g++.dg/modules/string-1_b.C | 5 + gcc/testsuite/g++.dg/modules/string-view1.C | 6 + gcc/testsuite/g++.dg/modules/string-view2.C | 56 +++++++ gcc/testsuite/g++.dg/modules/tinfo-1.C | 20 +++ gcc/testsuite/g++.dg/modules/tinfo-2_a.H | 4 + gcc/testsuite/g++.dg/modules/tinfo-2_b.C | 4 + gcc/testsuite/g++.dg/modules/tname-spec-1_a.H | 15 ++ gcc/testsuite/g++.dg/modules/tname-spec-1_b.C | 16 ++ .../g++.dg/modules/xtreme-header-1.h | 19 +++ .../g++.dg/modules/xtreme-header-1_a.H | 4 + .../g++.dg/modules/xtreme-header-1_b.C | 4 + .../g++.dg/modules/xtreme-header-1_c.C | 3 + .../g++.dg/modules/xtreme-header-2.h | 14 ++ .../g++.dg/modules/xtreme-header-2_a.H | 4 + .../g++.dg/modules/xtreme-header-2_b.C | 4 + .../g++.dg/modules/xtreme-header-2_c.C | 3 + .../g++.dg/modules/xtreme-header-3.h | 21 +++ .../g++.dg/modules/xtreme-header-3_a.H | 4 + .../g++.dg/modules/xtreme-header-3_b.C | 4 + .../g++.dg/modules/xtreme-header-3_c.C | 3 + .../g++.dg/modules/xtreme-header-4.h | 17 +++ .../g++.dg/modules/xtreme-header-4_a.H | 4 + .../g++.dg/modules/xtreme-header-4_b.C | 4 + .../g++.dg/modules/xtreme-header-4_c.C | 3 + .../g++.dg/modules/xtreme-header-5.h | 22 +++ .../g++.dg/modules/xtreme-header-5_a.H | 4 + .../g++.dg/modules/xtreme-header-5_b.C | 4 + .../g++.dg/modules/xtreme-header-5_c.C | 3 + .../g++.dg/modules/xtreme-header-6.h | 22 +++ .../g++.dg/modules/xtreme-header-6_a.H | 4 + .../g++.dg/modules/xtreme-header-6_b.C | 4 + .../g++.dg/modules/xtreme-header-6_c.C | 3 + gcc/testsuite/g++.dg/modules/xtreme-header.h | 144 ++++++++++++++++++ .../g++.dg/modules/xtreme-header_a.H | 4 + .../g++.dg/modules/xtreme-header_b.C | 4 + gcc/testsuite/g++.dg/modules/xtreme-tr1.h | 11 ++ gcc/testsuite/g++.dg/modules/xtreme-tr1_a.H | 4 + gcc/testsuite/g++.dg/modules/xtreme-tr1_b.C | 4 + 57 files changed, 704 insertions(+) create mode 100644 gcc/testsuite/g++.dg/modules/binding-1_a.H create mode 100644 gcc/testsuite/g++.dg/modules/binding-1_b.H create mode 100644 gcc/testsuite/g++.dg/modules/binding-1_c.C create mode 100644 gcc/testsuite/g++.dg/modules/binding-2.H create mode 100644 gcc/testsuite/g++.dg/modules/builtin-3_a.C create mode 100644 gcc/testsuite/g++.dg/modules/global-2_a.C create mode 100644 gcc/testsuite/g++.dg/modules/global-2_b.C create mode 100644 gcc/testsuite/g++.dg/modules/global-3_a.C create mode 100644 gcc/testsuite/g++.dg/modules/global-3_b.C create mode 100644 gcc/testsuite/g++.dg/modules/hello-1_a.C create mode 100644 gcc/testsuite/g++.dg/modules/hello-1_b.C create mode 100644 gcc/testsuite/g++.dg/modules/iostream-1_a.H create mode 100644 gcc/testsuite/g++.dg/modules/iostream-1_b.C create mode 100644 gcc/testsuite/g++.dg/modules/part-5_a.C create mode 100644 gcc/testsuite/g++.dg/modules/part-5_b.C create mode 100644 gcc/testsuite/g++.dg/modules/part-5_c.C create mode 100644 gcc/testsuite/g++.dg/modules/stdio-1_a.H create mode 100644 gcc/testsuite/g++.dg/modules/stdio-1_b.C create mode 100644 gcc/testsuite/g++.dg/modules/string-1_a.H create mode 100644 gcc/testsuite/g++.dg/modules/string-1_b.C create mode 100644 gcc/testsuite/g++.dg/modules/string-view1.C create mode 100644 gcc/testsuite/g++.dg/modules/string-view2.C create mode 100644 gcc/testsuite/g++.dg/modules/tinfo-1.C create mode 100644 gcc/testsuite/g++.dg/modules/tinfo-2_a.H create mode 100644 gcc/testsuite/g++.dg/modules/tinfo-2_b.C create mode 100644 gcc/testsuite/g++.dg/modules/tname-spec-1_a.H create mode 100644 gcc/testsuite/g++.dg/modules/tname-spec-1_b.C create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-header-1.h create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-header-1_a.H create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-header-1_b.C create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-header-1_c.C create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-header-2.h create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-header-2_a.H create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-header-2_b.C create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-header-2_c.C create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-header-3.h create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-header-3_a.H create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-header-3_b.C create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-header-3_c.C create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-header-4.h create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-header-4_a.H create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-header-4_b.C create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-header-4_c.C create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-header-5.h create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-header-5_a.H create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-header-5_b.C create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-header-5_c.C create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-header-6.h create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-header-6_a.H create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-header-6_b.C create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-header-6_c.C create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-header.h create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-header_a.H create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-header_b.C create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-tr1.h create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-tr1_a.H create mode 100644 gcc/testsuite/g++.dg/modules/xtreme-tr1_b.C diff --git a/gcc/testsuite/g++.dg/modules/binding-1_a.H b/gcc/testsuite/g++.dg/modules/binding-1_a.H new file mode 100644 index 00000000000..2d2460d9039 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/binding-1_a.H @@ -0,0 +1,4 @@ +// { dg-additional-options -fmodule-header } +// { dg-module-cmi {} } + +#include diff --git a/gcc/testsuite/g++.dg/modules/binding-1_b.H b/gcc/testsuite/g++.dg/modules/binding-1_b.H new file mode 100644 index 00000000000..eb5140bc024 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/binding-1_b.H @@ -0,0 +1,4 @@ +// { dg-additional-options -fmodule-header } +// { dg-module-cmi {} } + +#include diff --git a/gcc/testsuite/g++.dg/modules/binding-1_c.C b/gcc/testsuite/g++.dg/modules/binding-1_c.C new file mode 100644 index 00000000000..b63f88fb99a --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/binding-1_c.C @@ -0,0 +1,7 @@ +// { dg-additional-options -fmodules-ts } + +export module hello; +// { dg-module-cmi hello } + +import "binding-1_a.H"; +import "binding-1_b.H"; diff --git a/gcc/testsuite/g++.dg/modules/binding-2.H b/gcc/testsuite/g++.dg/modules/binding-2.H new file mode 100644 index 00000000000..e82d7cf4a49 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/binding-2.H @@ -0,0 +1,9 @@ +// { dg-additional-options "-fmodule-header -Wextra" } +// { dg-module-cmi {} } + +void* operator new(__SIZE_TYPE__, void* __p) noexcept; +void* operator new[](__SIZE_TYPE__, void* __p) noexcept; + +void operator delete (void*, void*) noexcept; +void operator delete[](void*, void*) noexcept; + diff --git a/gcc/testsuite/g++.dg/modules/builtin-3_a.C b/gcc/testsuite/g++.dg/modules/builtin-3_a.C new file mode 100644 index 00000000000..ad30ccf2a01 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/builtin-3_a.C @@ -0,0 +1,44 @@ +// { dg-additional-options "-fmodules-ts -fdump-lang-module-blocks-alias-uid" } +module; +#include +export module builtins; +// { dg-module-cmi builtins } + +export inline unsigned length (char const *ptr) +{ + return __builtin_strlen (ptr); +} + +export inline int count (int a, ...) +{ + int c = 0; + + va_list args; + va_start (args, a); + while (va_arg (args, char *)) + c++; + va_end (args); + + return c; +} + +// { dg-final { scan-lang-dump-not {Cluster members:\n \[0\]=decl declaration '::__builtin_strlen'\n \[1\]=binding '::__builtin_strlen'\n} module } } +// { dg-final { scan-lang-dump {Wrote GMF:-[0-9]* function_decl:'::__builtin_strlen'@builtins} module } } +// { dg-final { scan-lang-dump {Writing:-[0-9]*'s named merge key \(decl\) function_decl:'::__builtin_strlen'} module } } +// { dg-final { scan-lang-dump-not {Writing tree:-[0-9]* function_decl:'__builtin_strlen'\(strlen\)} module } } + +// The implementation details of va_list's are target-specific. +// Usually one of two patterns though +// { dg-final { scan-lang-dump-not { Cluster members:\n \[0\]=decl declaration '::__builtin_va_list'\n \[1\]=binding '::__builtin_va_list'\n} module { target i?86-*-linux* x86_64-*-linux* } } } +// { dg-final { scan-lang-dump {Wrote GMF:-[0-9]* type_decl:'::__builtin_va_list'@builtins} module { target x86_64-*-linux* } } } +// { dg-final { scan-lang-dump {Writing:-[0-9]*'s named merge key \(decl\) type_decl:'::__builtin_va_list'} module { target x86_64-*-linux* } } } + +// { dg-final { scan-lang-dump {Writing:-1's named merge key \(decl\) type_decl:'::__gnuc_va_list'} module { target i?86-*-linux* *-*-darwin* } } } +// { dg-final { scan-lang-dump {Wrote GMF:-3 type_decl:'::__gnuc_va_list'@builtins} module { target i?86-*-linux* *-*-darwin* } } } + +// { dg-final { scan-lang-dump {Wrote fixed:[0-9]* record_type:'__va_list'} module { target aarch64*-*-linux* } } } +// { dg-final { scan-lang-dump {Wrote fixed:[0-9]* pointer_type:'::__builtin_va_list'} module { target powerpc*-*-linux* } } } + +// { dg-final { scan-lang-dump-not { Cluster members:\n \[0\]=decl declaration '::va_list'\n \[1\]=binding '::va_list'\n} module } } +// { dg-final { scan-lang-dump {Wrote GMF:-[0-9]* type_decl:'::va_list'@builtins} module } } +// { dg-final { scan-lang-dump {Writing:-[0-9]*'s named merge key \(decl\) type_decl:'::va_list'} module } } diff --git a/gcc/testsuite/g++.dg/modules/global-2_a.C b/gcc/testsuite/g++.dg/modules/global-2_a.C new file mode 100644 index 00000000000..7f86fe9ef3c --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/global-2_a.C @@ -0,0 +1,22 @@ +// { dg-module-do run } +// { dg-additional-options "-fmodules-ts -fdump-lang-module-graph" } +module; +#include +#include +export module logger; +// { dg-module-cmi logger } + +export void Log (char const *fmt, ...) +{ + va_list args; + va_start (args, fmt); + printf ("Logging:"); + vprintf (fmt, args); + printf ("\n"); + va_end (args); +} + +// { dg-final { scan-lang-dump {Dependencies of decl function_decl:'::Log'} module } } +// not reachable (body not inline) +// { dg-final { scan-lang-dump-not {Reachable GMF '::printf[^\n']*' added} module } } + diff --git a/gcc/testsuite/g++.dg/modules/global-2_b.C b/gcc/testsuite/g++.dg/modules/global-2_b.C new file mode 100644 index 00000000000..7d49e1d14ed --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/global-2_b.C @@ -0,0 +1,10 @@ +// { dg-additional-options "-fmodules-ts" } + +import logger; + +int main () +{ + Log ("hello world!"); + return 0; +} + diff --git a/gcc/testsuite/g++.dg/modules/global-3_a.C b/gcc/testsuite/g++.dg/modules/global-3_a.C new file mode 100644 index 00000000000..fe7bb849ae8 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/global-3_a.C @@ -0,0 +1,16 @@ +// { dg-module-do run } +// { dg-additional-options "-fmodules-ts -fdump-lang-module-graph" } +module; +#include +export module logger; +// { dg-module-cmi logger } + +export void Log (char const *msg) +{ + std::cout << "Logging:" << msg << "\n"; +} + +// { dg-final { scan-lang-dump {Dependencies of decl function_decl:'::Log'} module } } +// not reachable (body not inline) +// { dg-final { scan-lang-dump-not {Reachable GMF '::printf[^'\n]*' added} module } } + diff --git a/gcc/testsuite/g++.dg/modules/global-3_b.C b/gcc/testsuite/g++.dg/modules/global-3_b.C new file mode 100644 index 00000000000..da0a3994727 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/global-3_b.C @@ -0,0 +1,9 @@ +// { dg-additional-options "-fmodules-ts" } + +import logger; + +int main () +{ + Log ("hello world!"); + return 0; +} diff --git a/gcc/testsuite/g++.dg/modules/hello-1_a.C b/gcc/testsuite/g++.dg/modules/hello-1_a.C new file mode 100644 index 00000000000..75853d6c8ca --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/hello-1_a.C @@ -0,0 +1,12 @@ +// { dg-module-do run } +// { dg-additional-options -fmodules-ts } + +module; +#include +#include +export module hello; +// { dg-module-cmi hello } +export void greeter (std::string_view const &name) +{ + std::cout << "Hello " << name << "!\n"; +} diff --git a/gcc/testsuite/g++.dg/modules/hello-1_b.C b/gcc/testsuite/g++.dg/modules/hello-1_b.C new file mode 100644 index 00000000000..b7d78c476c6 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/hello-1_b.C @@ -0,0 +1,9 @@ +// { dg-additional-options -fmodules-ts } + +#include +import hello; +int main (void) +{ + greeter ("world"); + return 0; +} diff --git a/gcc/testsuite/g++.dg/modules/iostream-1_a.H b/gcc/testsuite/g++.dg/modules/iostream-1_a.H new file mode 100644 index 00000000000..00f8c192bd8 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/iostream-1_a.H @@ -0,0 +1,10 @@ +// { dg-module-do run } +// { dg-additional-options "-fmodule-header" } +// { dg-module-cmi {} } + +#ifndef MY_IOSTREAM_H +#define MY_IOSTREAM_H +/* Proxy iostream, because command line in flux. */ +#include + +#endif diff --git a/gcc/testsuite/g++.dg/modules/iostream-1_b.C b/gcc/testsuite/g++.dg/modules/iostream-1_b.C new file mode 100644 index 00000000000..8058a7f9062 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/iostream-1_b.C @@ -0,0 +1,9 @@ +// { dg-additional-options -fmodules-ts } + +import "iostream-1_a.H"; + +int main () +{ + std::cout << "hello world!\n"; + return 0; +} diff --git a/gcc/testsuite/g++.dg/modules/part-5_a.C b/gcc/testsuite/g++.dg/modules/part-5_a.C new file mode 100644 index 00000000000..7679691f5f7 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/part-5_a.C @@ -0,0 +1,13 @@ +// { dg-additional-options -fmodules-ts } + +// a bug report ICE with namespace introduced in partition. +export module module1:submodule1; +// { dg-module-cmi module1:submodule1 } + +export namespace nmspc{ + class Cl1{ + public: + Cl1(){} + int x=14; + }; +} diff --git a/gcc/testsuite/g++.dg/modules/part-5_b.C b/gcc/testsuite/g++.dg/modules/part-5_b.C new file mode 100644 index 00000000000..f86bdd6cc1a --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/part-5_b.C @@ -0,0 +1,6 @@ +// { dg-additional-options -fmodules-ts } + +export module module1; +// { dg-module-cmi module1 } + +export import :submodule1; diff --git a/gcc/testsuite/g++.dg/modules/part-5_c.C b/gcc/testsuite/g++.dg/modules/part-5_c.C new file mode 100644 index 00000000000..0f148c3fce3 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/part-5_c.C @@ -0,0 +1,10 @@ +// { dg-additional-options -fmodules-ts } + +#include +import module1; + +int main(int argc, char const *argv[]) { + nmspc::Cl1 c1; + std::cout << c1.x; + return 0; +} diff --git a/gcc/testsuite/g++.dg/modules/stdio-1_a.H b/gcc/testsuite/g++.dg/modules/stdio-1_a.H new file mode 100644 index 00000000000..9eda2331dd9 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/stdio-1_a.H @@ -0,0 +1,14 @@ +// { dg-module-do run } +// { dg-additional-options "-fmodule-header -fdump-lang-module" } +// { dg-module-cmi {} } + +#ifndef _PROXY_STDIO_H +#define _PROXY_STDIO_H +/* Proxy stdio.h, because command line in flux. */ +#include + +#endif +// There should be *lots* of depsets (209 for glibc today) +// { dg-final { scan-lang-dump {Writing section:60 } module } } +// { dg-final { scan-lang-dump {Depset:0 decl entity:[0-9]* function_decl:'::printf'} module } } +// { dg-final { scan-lang-dump {Depset:1 binding namespace_decl:'::printf'} module } } diff --git a/gcc/testsuite/g++.dg/modules/stdio-1_b.C b/gcc/testsuite/g++.dg/modules/stdio-1_b.C new file mode 100644 index 00000000000..f4ad9845d20 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/stdio-1_b.C @@ -0,0 +1,14 @@ +// { dg-additional-options "-fmodules-ts -fdump-lang-module" } + +import "stdio-1_a.H"; + +int main () +{ + printf ("hello world!\n"); + return 0; +} + +// { dg-final { scan-lang-dump {Bindings '::printf' section:} module } } +// { dg-final { scan-lang-dump {Lazily binding '::printf'@'[^\n]*stdio-1_a.H' section:} module } } +// Make sure we don't load spurious stuff +// { dg-final { scan-lang-dump-not {binding '::scanf'@'[^\n]*'} module } } diff --git a/gcc/testsuite/g++.dg/modules/string-1_a.H b/gcc/testsuite/g++.dg/modules/string-1_a.H new file mode 100644 index 00000000000..77c565f7ddf --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/string-1_a.H @@ -0,0 +1,4 @@ +// { dg-additional-options -fmodule-header } + +// { dg-module-cmi {} } +#include diff --git a/gcc/testsuite/g++.dg/modules/string-1_b.C b/gcc/testsuite/g++.dg/modules/string-1_b.C new file mode 100644 index 00000000000..098289c54f1 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/string-1_b.C @@ -0,0 +1,5 @@ +// { dg-additional-options "-fmodules-ts -fno-module-lazy" } + +#include +import "string-1_a.H"; + diff --git a/gcc/testsuite/g++.dg/modules/string-view1.C b/gcc/testsuite/g++.dg/modules/string-view1.C new file mode 100644 index 00000000000..f5391f39180 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/string-view1.C @@ -0,0 +1,6 @@ +// { dg-additional-options "-fmodules-ts" } +module; +#include +#include +export module foo; +// { dg-module-cmi foo } diff --git a/gcc/testsuite/g++.dg/modules/string-view2.C b/gcc/testsuite/g++.dg/modules/string-view2.C new file mode 100644 index 00000000000..dad30eabba6 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/string-view2.C @@ -0,0 +1,56 @@ +// { dg-additional-options "-fmodules-ts" } +// reduced from string-view1 through cvise. Broken under c++2a too. +// we were creating a hash slot, and then doing another lookup without +// initializing that first slot :( + +namespace std { +typedef int a; +int b; +decltype(nullptr) c; +namespace xyz {} +__builtin_va_list d; +int n; +int e; +int f; +int g; +int h; +int i; +int j; +int k; +typedef struct l m; +typedef struct aa w; +typedef struct x o; +typedef x p; +long q; +long r; +typedef l s; +extern p ab; +void t(); +void v(); +extern p ac; +void ad(); +int ae; +int af; +extern p ag; +extern p ah; +void ai(); +void y(); +int aj; +int ak; +int al; +char am; +int an; +a ao; +int ap; +int aq; +void z(); +int ar; +int as; +void at(); +void au(); +void av(); +void aw(); +int u; +namespace zz { +} +} diff --git a/gcc/testsuite/g++.dg/modules/tinfo-1.C b/gcc/testsuite/g++.dg/modules/tinfo-1.C new file mode 100644 index 00000000000..43dadc840fc --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/tinfo-1.C @@ -0,0 +1,20 @@ +// { dg-additional-options "-fmodules-ts -fdump-lang-module-uid" } +export module Foo; +// { dg-module-cmi Foo } + +struct B +{ +}; + +struct C : B +{ +}; + +inline void foo () +{ + throw C (); +} + +// { dg-final { scan-lang-dump {Writing typedef type_decl:'::__si_class_type_info_pseudo_9'} module } } +// { dg-final { scan-lang-dump {Wrote tinfo_type:-[0-9]* 9 '::__si_class_type_info_pseudo_9'} module } } +// { dg-final { scan-lang-dump-not {Writing tree:-[0-9]* type_decl:'__si_class_type_info_pseudo_9'} module } } diff --git a/gcc/testsuite/g++.dg/modules/tinfo-2_a.H b/gcc/testsuite/g++.dg/modules/tinfo-2_a.H new file mode 100644 index 00000000000..027abd22144 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/tinfo-2_a.H @@ -0,0 +1,4 @@ +// { dg-additional-options "-fmodule-header" } +// { dg-module-cmi {} } + +#include diff --git a/gcc/testsuite/g++.dg/modules/tinfo-2_b.C b/gcc/testsuite/g++.dg/modules/tinfo-2_b.C new file mode 100644 index 00000000000..15c5bf25552 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/tinfo-2_b.C @@ -0,0 +1,4 @@ +// { dg-additional-options "-fmodules-ts -fno-module-lazy" } + +import "tinfo-2_a.H"; + diff --git a/gcc/testsuite/g++.dg/modules/tname-spec-1_a.H b/gcc/testsuite/g++.dg/modules/tname-spec-1_a.H new file mode 100644 index 00000000000..d517742c44c --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/tname-spec-1_a.H @@ -0,0 +1,15 @@ +// { dg-module-do run } +// { dg-additional-options -fmodule-header } + +template class _Op> +using __detected_or_t = long; + +template +struct pointer_traits +{ + template + using __difference_type = typename _Tp::difference_type; + + using difference_type = __detected_or_t<__difference_type>; +}; + diff --git a/gcc/testsuite/g++.dg/modules/tname-spec-1_b.C b/gcc/testsuite/g++.dg/modules/tname-spec-1_b.C new file mode 100644 index 00000000000..5028b7881ee --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/tname-spec-1_b.C @@ -0,0 +1,16 @@ +// { dg-additional-options -fmodules-ts } + +#include +import "tname-spec-1_a.H"; + +struct X +{ + using difference_type = char; +}; + +pointer_traits::difference_type x; + +int main () +{ + return !(typeid (x) == typeid (long)); +} diff --git a/gcc/testsuite/g++.dg/modules/xtreme-header-1.h b/gcc/testsuite/g++.dg/modules/xtreme-header-1.h new file mode 100644 index 00000000000..a7c635c8d15 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-header-1.h @@ -0,0 +1,19 @@ +// All the headers tickle a location bug. so subsets of the STL :( + +// C compatibility +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/gcc/testsuite/g++.dg/modules/xtreme-header-1_a.H b/gcc/testsuite/g++.dg/modules/xtreme-header-1_a.H new file mode 100644 index 00000000000..f30dacce0cc --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-header-1_a.H @@ -0,0 +1,4 @@ +// { dg-additional-options -fmodule-header } + +// { dg-module-cmi {} } +#include "xtreme-header-1.h" diff --git a/gcc/testsuite/g++.dg/modules/xtreme-header-1_b.C b/gcc/testsuite/g++.dg/modules/xtreme-header-1_b.C new file mode 100644 index 00000000000..e2730163ffc --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-header-1_b.C @@ -0,0 +1,4 @@ +// { dg-additional-options "-fmodules-ts -fno-module-lazy" } + +#include "xtreme-header-1.h" +import "xtreme-header-1_a.H"; diff --git a/gcc/testsuite/g++.dg/modules/xtreme-header-1_c.C b/gcc/testsuite/g++.dg/modules/xtreme-header-1_c.C new file mode 100644 index 00000000000..081a3020c67 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-header-1_c.C @@ -0,0 +1,3 @@ +// { dg-additional-options "-fmodules-ts -fno-module-lazy" } + +import "xtreme-header-1_a.H"; diff --git a/gcc/testsuite/g++.dg/modules/xtreme-header-2.h b/gcc/testsuite/g++.dg/modules/xtreme-header-2.h new file mode 100644 index 00000000000..ded093e533c --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-header-2.h @@ -0,0 +1,14 @@ +// Everything that transitively includes + +#include +// FIXME: PR 97549 +// #include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/gcc/testsuite/g++.dg/modules/xtreme-header-2_a.H b/gcc/testsuite/g++.dg/modules/xtreme-header-2_a.H new file mode 100644 index 00000000000..217ead37d25 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-header-2_a.H @@ -0,0 +1,4 @@ +// { dg-additional-options -fmodule-header } + +// { dg-module-cmi {} } +#include "xtreme-header-2.h" diff --git a/gcc/testsuite/g++.dg/modules/xtreme-header-2_b.C b/gcc/testsuite/g++.dg/modules/xtreme-header-2_b.C new file mode 100644 index 00000000000..1f608ec29b7 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-header-2_b.C @@ -0,0 +1,4 @@ +// { dg-additional-options "-fmodules-ts -fno-module-lazy" } + +#include "xtreme-header-2.h" +import "xtreme-header-2_a.H"; diff --git a/gcc/testsuite/g++.dg/modules/xtreme-header-2_c.C b/gcc/testsuite/g++.dg/modules/xtreme-header-2_c.C new file mode 100644 index 00000000000..bd942c368fd --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-header-2_c.C @@ -0,0 +1,3 @@ +// { dg-additional-options "-fmodules-ts -fno-module-lazy" } + +import "xtreme-header-2_a.H"; diff --git a/gcc/testsuite/g++.dg/modules/xtreme-header-3.h b/gcc/testsuite/g++.dg/modules/xtreme-header-3.h new file mode 100644 index 00000000000..bbfef0a7ef8 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-header-3.h @@ -0,0 +1,21 @@ +// Containers (except ranges-including ones) + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/gcc/testsuite/g++.dg/modules/xtreme-header-3_a.H b/gcc/testsuite/g++.dg/modules/xtreme-header-3_a.H new file mode 100644 index 00000000000..d3ff6fd4b56 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-header-3_a.H @@ -0,0 +1,4 @@ +// { dg-additional-options -fmodule-header } + +// { dg-module-cmi {} } +#include "xtreme-header-3.h" diff --git a/gcc/testsuite/g++.dg/modules/xtreme-header-3_b.C b/gcc/testsuite/g++.dg/modules/xtreme-header-3_b.C new file mode 100644 index 00000000000..2eb3145c944 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-header-3_b.C @@ -0,0 +1,4 @@ +// { dg-additional-options "-fmodules-ts -fno-module-lazy" } + +#include "xtreme-header-3.h" +import "xtreme-header-3_a.H"; diff --git a/gcc/testsuite/g++.dg/modules/xtreme-header-3_c.C b/gcc/testsuite/g++.dg/modules/xtreme-header-3_c.C new file mode 100644 index 00000000000..0852b71500f --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-header-3_c.C @@ -0,0 +1,3 @@ +// { dg-additional-options "-fmodules-ts -fno-module-lazy" } + +import "xtreme-header-3_a.H"; diff --git a/gcc/testsuite/g++.dg/modules/xtreme-header-4.h b/gcc/testsuite/g++.dg/modules/xtreme-header-4.h new file mode 100644 index 00000000000..4c918bca56b --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-header-4.h @@ -0,0 +1,17 @@ +// io + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/gcc/testsuite/g++.dg/modules/xtreme-header-4_a.H b/gcc/testsuite/g++.dg/modules/xtreme-header-4_a.H new file mode 100644 index 00000000000..391adbe8ebf --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-header-4_a.H @@ -0,0 +1,4 @@ +// { dg-additional-options -fmodule-header } + +// { dg-module-cmi {} } +#include "xtreme-header-4.h" diff --git a/gcc/testsuite/g++.dg/modules/xtreme-header-4_b.C b/gcc/testsuite/g++.dg/modules/xtreme-header-4_b.C new file mode 100644 index 00000000000..ff7147ebf64 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-header-4_b.C @@ -0,0 +1,4 @@ +// { dg-additional-options "-fmodules-ts -fno-module-lazy" } + +#include "xtreme-header-4.h" +import "xtreme-header-4_a.H"; diff --git a/gcc/testsuite/g++.dg/modules/xtreme-header-4_c.C b/gcc/testsuite/g++.dg/modules/xtreme-header-4_c.C new file mode 100644 index 00000000000..829a0e915fd --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-header-4_c.C @@ -0,0 +1,3 @@ +// { dg-additional-options "-fmodules-ts -fno-module-lazy" } + +import "xtreme-header-4_a.H"; diff --git a/gcc/testsuite/g++.dg/modules/xtreme-header-5.h b/gcc/testsuite/g++.dg/modules/xtreme-header-5.h new file mode 100644 index 00000000000..ed43541aaf3 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-header-5.h @@ -0,0 +1,22 @@ +// Remaining C++17 headers + +// C++ 17 and below +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/gcc/testsuite/g++.dg/modules/xtreme-header-5_a.H b/gcc/testsuite/g++.dg/modules/xtreme-header-5_a.H new file mode 100644 index 00000000000..a03c0241c9e --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-header-5_a.H @@ -0,0 +1,4 @@ +// { dg-additional-options -fmodule-header } + +// { dg-module-cmi {} } +#include "xtreme-header-5.h" diff --git a/gcc/testsuite/g++.dg/modules/xtreme-header-5_b.C b/gcc/testsuite/g++.dg/modules/xtreme-header-5_b.C new file mode 100644 index 00000000000..8cf7d6856b9 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-header-5_b.C @@ -0,0 +1,4 @@ +// { dg-additional-options "-fmodules-ts -fno-module-lazy" } + +#include "xtreme-header-5.h" +import "xtreme-header-5_a.H"; diff --git a/gcc/testsuite/g++.dg/modules/xtreme-header-5_c.C b/gcc/testsuite/g++.dg/modules/xtreme-header-5_c.C new file mode 100644 index 00000000000..c1ddb4c5be4 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-header-5_c.C @@ -0,0 +1,3 @@ +// { dg-additional-options "-fmodules-ts -fno-module-lazy" } + +import "xtreme-header-5_a.H"; diff --git a/gcc/testsuite/g++.dg/modules/xtreme-header-6.h b/gcc/testsuite/g++.dg/modules/xtreme-header-6.h new file mode 100644 index 00000000000..85894b2b20a --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-header-6.h @@ -0,0 +1,22 @@ +// C++20 headers +#if __cplusplus > 201703 +#include +#include +#include +#include +#if __cpp_coroutines +#include +#endif +#include +#include +#include +#if 0 +// Unimplemented +#include +#include +#include +#include +#include +#include +#endif +#endif diff --git a/gcc/testsuite/g++.dg/modules/xtreme-header-6_a.H b/gcc/testsuite/g++.dg/modules/xtreme-header-6_a.H new file mode 100644 index 00000000000..aec5a031fc6 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-header-6_a.H @@ -0,0 +1,4 @@ +// { dg-additional-options -fmodule-header } + +// { dg-module-cmi {} } +#include "xtreme-header-6.h" diff --git a/gcc/testsuite/g++.dg/modules/xtreme-header-6_b.C b/gcc/testsuite/g++.dg/modules/xtreme-header-6_b.C new file mode 100644 index 00000000000..0d2cc69df54 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-header-6_b.C @@ -0,0 +1,4 @@ +// { dg-additional-options "-fmodules-ts -fno-module-lazy" } + +#include "xtreme-header-6.h" +import "xtreme-header-6_a.H"; diff --git a/gcc/testsuite/g++.dg/modules/xtreme-header-6_c.C b/gcc/testsuite/g++.dg/modules/xtreme-header-6_c.C new file mode 100644 index 00000000000..2962a25c697 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-header-6_c.C @@ -0,0 +1,3 @@ +// { dg-additional-options "-fmodules-ts -fno-module-lazy" } + +import "xtreme-header-6_a.H"; diff --git a/gcc/testsuite/g++.dg/modules/xtreme-header.h b/gcc/testsuite/g++.dg/modules/xtreme-header.h new file mode 100644 index 00000000000..41302c780b5 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-header.h @@ -0,0 +1,144 @@ +// All the headers! + +#if __cplusplus > 201703L +// FIXME: if we include everything, something goes wrong with location +// information. We used to not handle lambdas attached to global +// vars, and this is a convienient flag to stop including everything. +#define NO_ASSOCIATED_LAMBDA 1 +#endif + +// C++ 17 and below +#if 1 +#if !NO_ASSOCIATED_LAMBDA +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if !NO_ASSOCIATED_LAMBDA +// FIXME: PR 97549 +//#include +#endif +#include +#include +#include +#if !NO_ASSOCIATED_LAMBDA +#include +#endif +#if !NO_ASSOCIATED_LAMBDA +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if !NO_ASSOCIATED_LAMBDA +#include +#endif +#if !NO_ASSOCIATED_LAMBDA +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#if !NO_ASSOCIATED_LAMBDA +#include +#endif +#if !NO_ASSOCIATED_LAMBDA +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if !NO_ASSOCIATED_LAMBDA +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#if !NO_ASSOCIATED_LAMBDA +#include +#endif +#include +#include +#endif + +// C compatibility +#if 1 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +// C++20 +#if __cplusplus > 201703 +#if 1 +#include +#include +#include +#include +#if __cpp_coroutines +#include +#endif +#if !NO_ASSOCIATED_LAMBDA +#include +#endif +#include +#include +#include +#if 0 +// Unimplemented +#include +#include +#include +#include +#include +#include +#endif +#endif +#endif diff --git a/gcc/testsuite/g++.dg/modules/xtreme-header_a.H b/gcc/testsuite/g++.dg/modules/xtreme-header_a.H new file mode 100644 index 00000000000..bf7859fba99 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-header_a.H @@ -0,0 +1,4 @@ +// { dg-additional-options -fmodule-header } + +// { dg-module-cmi {} } +#include "xtreme-header.h" diff --git a/gcc/testsuite/g++.dg/modules/xtreme-header_b.C b/gcc/testsuite/g++.dg/modules/xtreme-header_b.C new file mode 100644 index 00000000000..2e736da36dc --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-header_b.C @@ -0,0 +1,4 @@ +// { dg-additional-options "-fmodules-ts -fno-module-lazy" } + +#include "xtreme-header.h" +import "xtreme-header_a.H"; diff --git a/gcc/testsuite/g++.dg/modules/xtreme-tr1.h b/gcc/testsuite/g++.dg/modules/xtreme-tr1.h new file mode 100644 index 00000000000..8fe13993cab --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-tr1.h @@ -0,0 +1,11 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/gcc/testsuite/g++.dg/modules/xtreme-tr1_a.H b/gcc/testsuite/g++.dg/modules/xtreme-tr1_a.H new file mode 100644 index 00000000000..bed70a683bb --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-tr1_a.H @@ -0,0 +1,4 @@ +// { dg-additional-options -fmodule-header } + +// { dg-module-cmi {} } +#include "xtreme-tr1.h" diff --git a/gcc/testsuite/g++.dg/modules/xtreme-tr1_b.C b/gcc/testsuite/g++.dg/modules/xtreme-tr1_b.C new file mode 100644 index 00000000000..9bb1dc294ad --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/xtreme-tr1_b.C @@ -0,0 +1,4 @@ +// { dg-additional-options "-fmodules-ts -fno-module-lazy" } + +#include "xtreme-tr1.h" +import "xtreme-tr1_a.H"; -- 2.30.2