]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite: Adjust dg-error for -fimplicit-constexpr
authorMarek Polacek <polacek@redhat.com>
Fri, 2 Dec 2022 19:43:26 +0000 (14:43 -0500)
committerMarek Polacek <polacek@redhat.com>
Fri, 2 Dec 2022 19:47:45 +0000 (14:47 -0500)
Some of the new tests were failing with -fimplicit-constexpr.  This
patch adjusts the expected diagnostic.  Tested with

GXX_TESTSUITE_STDS=98,11,14,17,20,23 make check-c++ RUNTESTFLAGS="--target_board=unix\{,-fimplicit-constexpr\} dg.exp=spaceship-eq3.C"

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/constexpr-ex1.C: Adjust dg-error.
* g++.dg/cpp23/constexpr-nonlit10.C: Adjust dg-warning.
* g++.dg/cpp23/constexpr-nonlit11.C: Likewise.
* g++.dg/cpp2a/spaceship-eq3.C: Add dg-error.

gcc/testsuite/g++.dg/cpp0x/constexpr-ex1.C
gcc/testsuite/g++.dg/cpp23/constexpr-nonlit10.C
gcc/testsuite/g++.dg/cpp23/constexpr-nonlit11.C
gcc/testsuite/g++.dg/cpp2a/spaceship-eq3.C

index 48281a477844d06ccad6e1384a063f3cbcd329c9..383d38a42d452a19e088f5459a7f34b2cc1ea9bc 100644 (file)
@@ -87,8 +87,8 @@ struct resource {
   }
 };
 constexpr resource f(resource d)
-{ return d; }                  // { dg-error "non-.constexpr." "" { target { { ! implicit_constexpr } && c++20_down } } }
-// { dg-error "non-.constexpr." "" { target c++23 } .-2 }
-constexpr resource d = f(9);   // { dg-message ".constexpr." "" { target { ! implicit_constexpr } } }
+{ return d; }                  // { dg-error "non-.constexpr." "" { target { { { ! implicit_constexpr } && c++20_down } || c++11_only } } }
+// { dg-error "non-.constexpr." "" { target { c++23 && { ! implicit_constexpr } } } .-2 }
+constexpr resource d = f(9);   // { dg-message ".constexpr." "" { target { { ! implicit_constexpr } || c++11_only } } }
 
 // 4.4 floating-point constant expressions
index 48706f7b66e95a65b2e918b89e62057d2ecdfbda..31d4b873bbf8da94b5b5411bee0d1532cb93f2ed 100644 (file)
@@ -11,13 +11,13 @@ struct NonLiteral {
 // C++23: It is possible to write a constexpr function for which no
 // invocation satisfies the requirements of a core constant expression.
 constexpr NonLiteral
-fn0 (int) // { dg-warning "invalid return type" }
+fn0 (int) // { dg-warning "invalid return type" "" { target { ! implicit_constexpr } } }
 {
   return NonLiteral{};
 }
 
 constexpr int
-fn1 (NonLiteral) // { dg-warning "invalid type" }
+fn1 (NonLiteral) // { dg-warning "invalid type" "" { target { ! implicit_constexpr } } }
 {
   return 42;
 }
index a7114bc66cbd9d10c3bac3de0e70571188a3eef3..e08809f873cfde101809b7873154ee08a9ee70d3 100644 (file)
@@ -25,10 +25,10 @@ struct X {
 struct S {
   X x;
   // Calls a non-constexpr constructor X::X(int).
-  constexpr S(int i) : x(i) { } // { dg-warning "call to" }
+  constexpr S(int i) : x(i) { } // { dg-warning "call to" "" { target { ! implicit_constexpr } } }
   S(int, int) { }
   // Target constructor isn't constexpr.
-  constexpr S() : S(42, 42) { } // { dg-warning "call to" }
+  constexpr S() : S(42, 42) { } // { dg-warning "call to" "" { target { ! implicit_constexpr } } }
 };
 
 namespace N1 {
index 69eaa7b9b209d274772097334dfeafeb2ea75818..246839f1f955f473e6758cd6da3d2626a1ffaa94 100644 (file)
@@ -9,6 +9,7 @@ struct D
   A i;
   bool operator==(const D& x) const = default; // { dg-error "A::operator==" "" { target c++20_down } }
   bool operator!=(const D& z) const = default; // { dg-error "D::operator==" "" { target c++20_down } }
+// { dg-error "called" "" { target { c++23 && implicit_constexpr } } .-1 }
 };
 
 constexpr D d{A()};