diff options
Diffstat (limited to 'gcc/testsuite/g++.dg')
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1y/constexpr-prvalue1.C | 12 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1y/constexpr-prvalue1a.C | 33 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/modules/lambda-8_b.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/modules/leg-merge-4_c.C | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/modules/noexcept-4_a.H | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/modules/noexcept-4_b.C | 18 |
6 files changed, 68 insertions, 9 deletions
diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-prvalue1.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-prvalue1.C index ad31e30..6ad2ec8 100644 --- a/gcc/testsuite/g++.dg/cpp1y/constexpr-prvalue1.C +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-prvalue1.C @@ -1,6 +1,6 @@ // PR c++/116416 // { dg-do compile { target c++14 } } -// { dg-options "-O" } +// { dg-options "-O -fdump-tree-original" } struct Str { constexpr Str() {} @@ -17,14 +17,16 @@ extern void callback(Str str); void func1() { - callback(Str{"Test"}); + callback(Str{"Test1"}); } void func2() { - Str str{"Test"}; + Str str{"Test2"}; callback(str); } -// Check that we don't call Str::Str(char const*) -// { dg-final { scan-assembler-not "_ZN3StrC1EPKc" } } +// Check that the front end folds both the temporary initializer and +// that of 'str'. +// { dg-final { scan-tree-dump "{.str=\\(const char \\*\\) \"Test1\", .length=5}" "original" } } +// { dg-final { scan-tree-dump "{.str=\\(const char \\*\\) \"Test2\", .length=5}" "original" } } diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-prvalue1a.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-prvalue1a.C new file mode 100644 index 0000000..54176bf --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-prvalue1a.C @@ -0,0 +1,33 @@ +// PR c++/116416 +// A version of constexpr-prvalue1.C that calls __builtin_is_constant_evaluated. +// { dg-do compile { target c++14 } } +// { dg-options "-O -fdump-tree-original" } + +struct Str { + constexpr Str() {} + constexpr Str(const char *instr) { + str = instr; length = 0; + for (auto index = 0; instr[index]; ++index) { + length += __builtin_is_constant_evaluated() ? 1 : 1; + } + } + const char *str = nullptr; + int length = 0; +}; +extern void callback(Str str); +void +func1() +{ + callback(Str{"Test1"}); +} +void +func2() +{ + Str str{"Test2"}; + callback(str); +} + +// Check that the front end folds both the temporary initializer and +// that of 'str'. +// { dg-final { scan-tree-dump "{.str=\\(const char \\*\\) \"Test1\", .length=5}" "original" } } +// { dg-final { scan-tree-dump "{.str=\\(const char \\*\\) \"Test2\", .length=5}" "original" } } diff --git a/gcc/testsuite/g++.dg/modules/lambda-8_b.C b/gcc/testsuite/g++.dg/modules/lambda-8_b.C index 7ace494..96578ba 100644 --- a/gcc/testsuite/g++.dg/modules/lambda-8_b.C +++ b/gcc/testsuite/g++.dg/modules/lambda-8_b.C @@ -4,4 +4,4 @@ #include "lambda-8.h" import "lambda-8_a.H"; -// { dg-error "conflicting global module declaration" "" { target *-*-* } 0 } +// { dg-error "conflicting imported declaration" "" { target *-*-* } 0 } diff --git a/gcc/testsuite/g++.dg/modules/leg-merge-4_c.C b/gcc/testsuite/g++.dg/modules/leg-merge-4_c.C index f1b1aeb..5756057 100644 --- a/gcc/testsuite/g++.dg/modules/leg-merge-4_c.C +++ b/gcc/testsuite/g++.dg/modules/leg-merge-4_c.C @@ -11,8 +11,8 @@ void foo () X *p; } -// { dg-regexp "\nIn module \[^\n]*leg-merge-4_b.H, imported at \[^\n]*leg-merge-4_c.C:\[0-9]*:\n\[^\n]*leg-merge-4_b.H:4:\[0-9]*: error: conflicting global module declaration 'float bob'\nIn module \[^\n]*leg-merge-4_a.H, imported at \[^\n]*leg-merge-4_c.C:\[0-9]*:\n\[^\n]*leg-merge-4_a.H:4:\[0-9]*: note: existing declaration 'int bob'\n\[^\n]*leg-merge-4_c.C:9:\[0-9]*: note: during load of binding '::bob'$" } +// { dg-regexp "\nIn module \[^\n]*leg-merge-4_b.H, imported at \[^\n]*leg-merge-4_c.C:\[0-9]*:\n\[^\n]*leg-merge-4_b.H:4:\[0-9]*: error: conflicting type for imported declaration 'float bob'\nIn module \[^\n]*leg-merge-4_a.H, imported at \[^\n]*leg-merge-4_c.C:\[0-9]*:\n\[^\n]*leg-merge-4_a.H:4:\[0-9]*: note: existing declaration 'int bob'\n\[^\n]*leg-merge-4_c.C:9:\[0-9]*: note: during load of binding '::bob'$" } -// { dg-regexp "\nIn module \[^\n]*leg-merge-4_b.H, imported at \[^\n]*leg-merge-4_c.C:\[0-9]*:\n\[^\n]*leg-merge-4_b.H:5:\[0-9]*: error: conflicting global module declaration 'int frob\\(\\)'\nIn module \[^\n]*leg-merge-4_a.H, imported at \[^\n]*leg-merge-4_c.C:\[0-9]*:\n\[^\n]*leg-merge-4_a.H:5:\[0-9]*: note: existing declaration 'void frob\\(\\)'\n\[^\n]*leg-merge-4_c.C:10:\[0-9]*: note: during load of binding '::frob'$" } +// { dg-regexp "\nIn module \[^\n]*leg-merge-4_b.H, imported at \[^\n]*leg-merge-4_c.C:\[0-9]*:\n\[^\n]*leg-merge-4_b.H:5:\[0-9]*: error: conflicting type for imported declaration 'int frob\\(\\)'\nIn module \[^\n]*leg-merge-4_a.H, imported at \[^\n]*leg-merge-4_c.C:\[0-9]*:\n\[^\n]*leg-merge-4_a.H:5:\[0-9]*: note: existing declaration 'void frob\\(\\)'\n\[^\n]*leg-merge-4_c.C:10:\[0-9]*: note: during load of binding '::frob'$" } -// { dg-regexp "In module \[^\n]*leg-merge-4_b.H, imported at \[^\n]*leg-merge-4_c.C:\[0-9]*:\n\[^\n]*leg-merge-4_b.H:6:\[0-9]*: error: conflicting global module declaration 'union X'\nIn module \[^\n]*leg-merge-4_a.H, imported at \[^\n]*leg-merge-4_c.C:\[0-9]*:\n\[^\n]*leg-merge-4_a.H:6:\[0-9]*: note: existing declaration 'class X'\n\[^\n]*leg-merge-4_c.C:11:\[0-9]*: note: during load of binding '::X'$" } +// { dg-regexp "In module \[^\n]*leg-merge-4_b.H, imported at \[^\n]*leg-merge-4_c.C:\[0-9]*:\n\[^\n]*leg-merge-4_b.H:6:\[0-9]*: error: conflicting type for imported declaration 'union X'\nIn module \[^\n]*leg-merge-4_a.H, imported at \[^\n]*leg-merge-4_c.C:\[0-9]*:\n\[^\n]*leg-merge-4_a.H:6:\[0-9]*: note: existing declaration 'class X'\n\[^\n]*leg-merge-4_c.C:11:\[0-9]*: note: during load of binding '::X'$" } diff --git a/gcc/testsuite/g++.dg/modules/noexcept-4_a.H b/gcc/testsuite/g++.dg/modules/noexcept-4_a.H new file mode 100644 index 0000000..b888a1b --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/noexcept-4_a.H @@ -0,0 +1,6 @@ +// { dg-additional-options "-fmodule-header -std=c++20" } +// { dg-module-cmi {} } + +struct exception_ptr { + friend bool operator==(const exception_ptr&, const exception_ptr&) = default; +}; diff --git a/gcc/testsuite/g++.dg/modules/noexcept-4_b.C b/gcc/testsuite/g++.dg/modules/noexcept-4_b.C new file mode 100644 index 0000000..7cc5531 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/noexcept-4_b.C @@ -0,0 +1,18 @@ +// { dg-additional-options "-fmodules -std=c++20" } + +struct exception_ptr { + friend bool operator==(const exception_ptr&, const exception_ptr&) = default; +}; + +void enqueue() { + exception_ptr e; + e == e; +} + +import "noexcept-4_a.H"; + +int main() { + constexpr exception_ptr e; + static_assert(e == e); + static_assert(noexcept(e == e)); +} |