c++: Add tests for fixed PRs.
Bugzilla inspection turned up a bunch of old(er) PRs that have been fixed. Let's include them not to regress in the future. gcc/testsuite/ChangeLog: PR c++/87530 PR c++/58156 PR c++/68828 PR c++/86002 PR c++/91525 PR c++/96223 PR c++/87032 PR c++/35098 * g++.dg/cpp0x/move-return4.C: New test. * g++.dg/cpp0x/vt-58156.C: New test. * g++.dg/cpp2a/concepts-pr68828.C: New test. * g++.dg/cpp2a/concepts-pr86002.C: New test. * g++.dg/cpp2a/concepts-pr91525.C: New test. * g++.dg/cpp2a/constexpr-indeterminate1.C: New test. * g++.dg/cpp2a/desig17.C: New test. * g++.dg/ext/attrib62.C: New test.
This commit is contained in:
parent
c560591408
commit
4f0aa5b051
17
gcc/testsuite/g++.dg/cpp0x/move-return4.C
Normal file
17
gcc/testsuite/g++.dg/cpp0x/move-return4.C
Normal file
@ -0,0 +1,17 @@
|
||||
// PR c++/87530
|
||||
// { dg-do compile { target c++11 } }
|
||||
|
||||
struct Base { };
|
||||
|
||||
template<typename T>
|
||||
struct A : Base
|
||||
{
|
||||
A();
|
||||
A(Base&&);
|
||||
};
|
||||
|
||||
A<int> foo()
|
||||
{
|
||||
A<double> v;
|
||||
return v; // { dg-error "cannot bind rvalue reference" "" { target c++17_down } }
|
||||
}
|
13
gcc/testsuite/g++.dg/cpp0x/vt-58156.C
Normal file
13
gcc/testsuite/g++.dg/cpp0x/vt-58156.C
Normal file
@ -0,0 +1,13 @@
|
||||
// PR c++/58156
|
||||
// { dg-do compile { target c++11 } }
|
||||
|
||||
template <class T, class... U>
|
||||
void Foo(U&...) {}
|
||||
|
||||
template <class T, class... U>
|
||||
void Foo(const U&...) {}
|
||||
|
||||
void Bar() {
|
||||
const int a = 0;
|
||||
Foo<int>(a);
|
||||
}
|
35
gcc/testsuite/g++.dg/cpp2a/concepts-pr68828.C
Normal file
35
gcc/testsuite/g++.dg/cpp2a/concepts-pr68828.C
Normal file
@ -0,0 +1,35 @@
|
||||
// PR c++/68828
|
||||
// { dg-do compile { target c++20 } }
|
||||
|
||||
template <typename... Types>
|
||||
struct Var
|
||||
{
|
||||
};
|
||||
|
||||
struct A
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
T
|
||||
forward(T t)
|
||||
{
|
||||
return static_cast<T>(t);
|
||||
}
|
||||
|
||||
template <typename V, typename... Types, typename... Args>
|
||||
bool requires_types_args(V&& v, Var<Types...>&, Args&&... args)
|
||||
{
|
||||
return (true && ... &&
|
||||
requires (V&& v, Types type, Args... args) {
|
||||
foo(forward<V>(v), forward<Types>(type),
|
||||
forward<Args>(args)...);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void bar()
|
||||
{
|
||||
Var<int, char> v;
|
||||
requires_types_args(A(), v, 1, 'b');
|
||||
}
|
19
gcc/testsuite/g++.dg/cpp2a/concepts-pr86002.C
Normal file
19
gcc/testsuite/g++.dg/cpp2a/concepts-pr86002.C
Normal file
@ -0,0 +1,19 @@
|
||||
// PR c++/86002
|
||||
// { dg-do compile { target c++20 } }
|
||||
|
||||
struct X {};
|
||||
struct Y { int i; };
|
||||
|
||||
template <typename T>
|
||||
int f(T t)
|
||||
{
|
||||
if constexpr (requires { t.i; })
|
||||
return t.i;
|
||||
else
|
||||
return {};
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
return f(X{}) + f(Y{});
|
||||
}
|
17
gcc/testsuite/g++.dg/cpp2a/concepts-pr91525.C
Normal file
17
gcc/testsuite/g++.dg/cpp2a/concepts-pr91525.C
Normal file
@ -0,0 +1,17 @@
|
||||
// PR c++/91525
|
||||
// { dg-do compile { target c++20 } }
|
||||
|
||||
struct X {
|
||||
void operator<<(long);
|
||||
void operator<<(bool);
|
||||
} x;
|
||||
struct B {
|
||||
template <bool = true> operator bool();
|
||||
template <bool = true> requires false operator bool();
|
||||
} b;
|
||||
|
||||
void
|
||||
fn()
|
||||
{
|
||||
x << b;
|
||||
}
|
46
gcc/testsuite/g++.dg/cpp2a/constexpr-indeterminate1.C
Normal file
46
gcc/testsuite/g++.dg/cpp2a/constexpr-indeterminate1.C
Normal file
@ -0,0 +1,46 @@
|
||||
// PR c++/96223
|
||||
// { dg-do compile { target c++20 } }
|
||||
// DR 1787 (if an indeterminate value is produced by an evaluation, the
|
||||
// behavior is undefined except in certain cases)
|
||||
// Note that P1331R2 explicitly disallows in a constant evaluation:
|
||||
// - an lvalue-to-rvalue conversion that is applied to an object with
|
||||
// indeterminate value ([basic.indet]).
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
constexpr int
|
||||
fn1 ()
|
||||
{
|
||||
unsigned char foo;
|
||||
unsigned char u = foo; // { dg-error "not usable in a constant expression" }
|
||||
return 0;
|
||||
}
|
||||
|
||||
constexpr int
|
||||
fn2 ()
|
||||
{
|
||||
unsigned char foo;
|
||||
int i = foo; // { dg-error "not usable in a constant expression" }
|
||||
return 0;
|
||||
}
|
||||
|
||||
constexpr int
|
||||
fn3 ()
|
||||
{
|
||||
unsigned char foo;
|
||||
char8_t u = foo; // { dg-error "not usable in a constant expression" }
|
||||
return 0;
|
||||
}
|
||||
|
||||
constexpr int
|
||||
fn4 ()
|
||||
{
|
||||
std::byte foo;
|
||||
std::byte b = foo; // { dg-error "not usable in a constant expression" }
|
||||
return 0;
|
||||
}
|
||||
|
||||
constexpr int w1 = fn1 ();
|
||||
constexpr int w2 = fn2 ();
|
||||
constexpr int w3 = fn3 ();
|
||||
constexpr int w4 = fn4 ();
|
19
gcc/testsuite/g++.dg/cpp2a/desig17.C
Normal file
19
gcc/testsuite/g++.dg/cpp2a/desig17.C
Normal file
@ -0,0 +1,19 @@
|
||||
// PR c++/87032
|
||||
// { dg-do compile { target c++20 } }
|
||||
|
||||
struct f1 {int x,y;};
|
||||
struct f2 {int x,y,z,t;};
|
||||
|
||||
struct T {
|
||||
const char * name;
|
||||
union {
|
||||
struct f1 fn1;
|
||||
struct f2 fn2;
|
||||
} d;
|
||||
};
|
||||
|
||||
extern "C" void p(struct T);
|
||||
|
||||
int main(){
|
||||
p({"%x",{.fn2={1,2,3,4}}});
|
||||
}
|
7
gcc/testsuite/g++.dg/ext/attrib62.C
Normal file
7
gcc/testsuite/g++.dg/ext/attrib62.C
Normal file
@ -0,0 +1,7 @@
|
||||
// PR c++/35098
|
||||
// { dg-do compile }
|
||||
|
||||
template<typename T> struct A
|
||||
{
|
||||
T a, __attribute((unused)) b; // { dg-warning "attribute ignored" }
|
||||
};
|
Loading…
Reference in New Issue
Block a user