[COMIITTED] Testsuite: Make dependence on -fdelete-null-pointer-checks explicit

Message ID 21d3892a-d5c8-3f35-7843-03f006676a88@codesourcery.com
State Committed
Headers
Series [COMIITTED] Testsuite: Make dependence on -fdelete-null-pointer-checks explicit |

Commit Message

Sandra Loosemore Jan. 9, 2022, 6:22 a.m. UTC
  I've checked in these tweaks for various testcases that fail on 
nios2-elf without an explicit -fdelete-null-pointer-checks option.  This 
target is configured to build with that optimization off by default.

-Sandra
  

Comments

Jonathan Wakely Jan. 10, 2022, 11:45 a.m. UTC | #1
CC libstdc++ and Jakub.

On 08/01/22 23:22 -0700, Sandra Loosemore wrote:
>I've checked in these tweaks for various testcases that fail on
>nios2-elf without an explicit -fdelete-null-pointer-checks option.  This
>target is configured to build with that optimization off by default.
>
>-Sandra
>
>commit 04c69d0e61c0f98a010d77a79ab749d5f0aa6b67
>Author: Sandra Loosemore <sandra@codesourcery.com>
>Date:   Sat Jan 8 22:02:13 2022 -0800
>
>    Testsuite: Make dependence on -fdelete-null-pointer-checks explicit
>
>    nios2-elf target defaults to -fno-delete-null-pointer-checks, breaking
>    tests that implicitly depend on that optimization.  Add the option
>    explicitly on these tests.
>
>    2022-01-08  Sandra Loosemore  <sandra@codesourcery.com>
>
>    	gcc/testsuite/
>    	* g++.dg/cpp0x/constexpr-compare1.C: Add explicit
>    	-fdelete-null-pointer-checks option.
>    	* g++.dg/cpp0x/constexpr-compare2.C: Likewise.
>    	* g++.dg/cpp0x/constexpr-typeid2.C: Likewise.
>    	* g++.dg/cpp1y/constexpr-94716.C: Likewise.
>    	* g++.dg/cpp1z/constexpr-compare1.C: Likewise.
>    	* g++.dg/cpp1z/constexpr-if36.C: Likewise.
>    	* gcc.dg/init-compare-1.c: Likewise.
>
>    	libstdc++-v3/
>    	* testsuite/18_support/type_info/constexpr.cc: Add explicit
>    	-fdelete-null-pointer-checks option.

This test should not be doing anything with null pointers. Instead of
working around the error on nios2-elf, I think the front-end needs
fixing.

Maybe something is not being folded early enough for the constexpr
evaluation to work. Jakub?

$ g++ -std=gnu++23  ~/src/gcc/gcc/libstdc++-v3/testsuite/18_support/type_info/constexpr.cc -c -fno-delete-null-pointer-checks
/home/jwakely/src/gcc/gcc/libstdc++-v3/testsuite/18_support/type_info/constexpr.cc:49:22: error: non-constant condition for static assertion
    49 | static_assert( test01() );
       |                ~~~~~~^~
In file included from /home/jwakely/src/gcc/gcc/libstdc++-v3/testsuite/18_support/type_info/constexpr.cc:5:
/home/jwakely/src/gcc/gcc/libstdc++-v3/testsuite/18_support/type_info/constexpr.cc:49:22:   in 'constexpr' expansion of 'test01()'
/home/jwakely/gcc/12/include/c++/12.0.0/typeinfo:196:19: error: '(((const std::type_info*)(& _ZTIi)) == ((const std::type_info*)(& _ZTIl)))' is not a constant expression
   196 |       return this == &__arg;
       |              ~~~~~^~~~~~~~~
  
Jonathan Wakely Jan. 13, 2022, 8:33 p.m. UTC | #2
On 10/01/22 11:45 +0000, Jonathan Wakely wrote:
>CC libstdc++ and Jakub.
>
>On 08/01/22 23:22 -0700, Sandra Loosemore wrote:
>>I've checked in these tweaks for various testcases that fail on
>>nios2-elf without an explicit -fdelete-null-pointer-checks option.  This
>>target is configured to build with that optimization off by default.
>>
>>-Sandra
>>
>>commit 04c69d0e61c0f98a010d77a79ab749d5f0aa6b67
>>Author: Sandra Loosemore <sandra@codesourcery.com>
>>Date:   Sat Jan 8 22:02:13 2022 -0800
>>
>>   Testsuite: Make dependence on -fdelete-null-pointer-checks explicit
>>
>>   nios2-elf target defaults to -fno-delete-null-pointer-checks, breaking
>>   tests that implicitly depend on that optimization.  Add the option
>>   explicitly on these tests.
>>
>>   2022-01-08  Sandra Loosemore  <sandra@codesourcery.com>
>>
>>   	gcc/testsuite/
>>   	* g++.dg/cpp0x/constexpr-compare1.C: Add explicit
>>   	-fdelete-null-pointer-checks option.
>>   	* g++.dg/cpp0x/constexpr-compare2.C: Likewise.
>>   	* g++.dg/cpp0x/constexpr-typeid2.C: Likewise.
>>   	* g++.dg/cpp1y/constexpr-94716.C: Likewise.
>>   	* g++.dg/cpp1z/constexpr-compare1.C: Likewise.
>>   	* g++.dg/cpp1z/constexpr-if36.C: Likewise.
>>   	* gcc.dg/init-compare-1.c: Likewise.
>>
>>   	libstdc++-v3/
>>   	* testsuite/18_support/type_info/constexpr.cc: Add explicit
>>   	-fdelete-null-pointer-checks option.
>
>This test should not be doing anything with null pointers. Instead of
>working around the error on nios2-elf, I think the front-end needs
>fixing.
>
>Maybe something is not being folded early enough for the constexpr
>evaluation to work. Jakub?
>
>$ g++ -std=gnu++23  ~/src/gcc/gcc/libstdc++-v3/testsuite/18_support/type_info/constexpr.cc -c -fno-delete-null-pointer-checks
>/home/jwakely/src/gcc/gcc/libstdc++-v3/testsuite/18_support/type_info/constexpr.cc:49:22: error: non-constant condition for static assertion
>   49 | static_assert( test01() );
>      |                ~~~~~~^~
>In file included from /home/jwakely/src/gcc/gcc/libstdc++-v3/testsuite/18_support/type_info/constexpr.cc:5:
>/home/jwakely/src/gcc/gcc/libstdc++-v3/testsuite/18_support/type_info/constexpr.cc:49:22:   in 'constexpr' expansion of 'test01()'
>/home/jwakely/gcc/12/include/c++/12.0.0/typeinfo:196:19: error: '(((const std::type_info*)(& _ZTIi)) == ((const std::type_info*)(& _ZTIl)))' is not a constant expression
>  196 |       return this == &__arg;
>      |              ~~~~~^~~~~~~~~

This is now https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104016
  

Patch

commit 04c69d0e61c0f98a010d77a79ab749d5f0aa6b67
Author: Sandra Loosemore <sandra@codesourcery.com>
Date:   Sat Jan 8 22:02:13 2022 -0800

    Testsuite: Make dependence on -fdelete-null-pointer-checks explicit
    
    nios2-elf target defaults to -fno-delete-null-pointer-checks, breaking
    tests that implicitly depend on that optimization.  Add the option
    explicitly on these tests.
    
    2022-01-08  Sandra Loosemore  <sandra@codesourcery.com>
    
    	gcc/testsuite/
    	* g++.dg/cpp0x/constexpr-compare1.C: Add explicit
    	-fdelete-null-pointer-checks option.
    	* g++.dg/cpp0x/constexpr-compare2.C: Likewise.
    	* g++.dg/cpp0x/constexpr-typeid2.C: Likewise.
    	* g++.dg/cpp1y/constexpr-94716.C: Likewise.
    	* g++.dg/cpp1z/constexpr-compare1.C: Likewise.
    	* g++.dg/cpp1z/constexpr-if36.C: Likewise.
    	* gcc.dg/init-compare-1.c: Likewise.
    
    	libstdc++-v3/
    	* testsuite/18_support/type_info/constexpr.cc: Add explicit
    	-fdelete-null-pointer-checks option.

diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-compare1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-compare1.C
index ad65019..603c6d5 100644
--- a/gcc/testsuite/g++.dg/cpp0x/constexpr-compare1.C
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-compare1.C
@@ -1,4 +1,5 @@ 
 // { dg-do compile { target c++11 } }
+// { dg-additional-options "-fdelete-null-pointer-checks" }
 
 extern int a, b;
 static_assert (&a == &a, "");
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-compare2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-compare2.C
index b1bc472..5c08dbb 100644
--- a/gcc/testsuite/g++.dg/cpp0x/constexpr-compare2.C
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-compare2.C
@@ -1,5 +1,6 @@ 
 // PR c++/69681
 // { dg-do compile { target c++11 } }
+// { dg-additional-options "-fdelete-null-pointer-checks" }
 
 void f();
 void g();
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-typeid2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-typeid2.C
index 78c6b8e..8ab76f9 100644
--- a/gcc/testsuite/g++.dg/cpp0x/constexpr-typeid2.C
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-typeid2.C
@@ -1,5 +1,6 @@ 
 // PR c++/103600
 // { dg-do compile { target c++11 } }
+// { dg-additional-options "-fdelete-null-pointer-checks" }
 
 #include <typeinfo>
 
diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-94716.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-94716.C
index 90173f3..5ac8720 100644
--- a/gcc/testsuite/g++.dg/cpp1y/constexpr-94716.C
+++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-94716.C
@@ -1,5 +1,6 @@ 
 // PR c++/94716
 // { dg-do compile { target c++14 } }
+// { dg-additional-options "-fdelete-null-pointer-checks" }
 
 template <int> char v = 0;
 static_assert (&v<2> == &v<2>, "");
diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-compare1.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-compare1.C
index a53c03c..d40d536 100644
--- a/gcc/testsuite/g++.dg/cpp1z/constexpr-compare1.C
+++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-compare1.C
@@ -1,4 +1,5 @@ 
 // { dg-do compile { target c++17 } }
+// { dg-additional-options "-fdelete-null-pointer-checks" }
 
 inline int a = 0;
 inline int b = 0;
diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-if36.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-if36.C
index 4a1b134..e425af2 100644
--- a/gcc/testsuite/g++.dg/cpp1z/constexpr-if36.C
+++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-if36.C
@@ -3,6 +3,7 @@ 
 // weakness.
 
 // { dg-do compile { target c++17 } }
+// { dg-additional-options "-fdelete-null-pointer-checks" }
 
 extern void weakfn1 (void);
 extern void weakfn2 (void);
diff --git a/gcc/testsuite/gcc.dg/init-compare-1.c b/gcc/testsuite/gcc.dg/init-compare-1.c
index 9208b66..6737c85 100644
--- a/gcc/testsuite/gcc.dg/init-compare-1.c
+++ b/gcc/testsuite/gcc.dg/init-compare-1.c
@@ -1,4 +1,5 @@ 
 /* { dg-do compile } */
+/* { dg-additional-options "-fdelete-null-pointer-checks" } */
 
 extern int a, b;
 int c = &a == &a;
diff --git a/libstdc++-v3/testsuite/18_support/type_info/constexpr.cc b/libstdc++-v3/testsuite/18_support/type_info/constexpr.cc
index 07f4fb6..6fb67b4 100644
--- a/libstdc++-v3/testsuite/18_support/type_info/constexpr.cc
+++ b/libstdc++-v3/testsuite/18_support/type_info/constexpr.cc
@@ -1,5 +1,6 @@ 
 // { dg-options "-std=gnu++23 -frtti" }
 // { dg-do compile { target c++23 } }
+// { dg-additional-options "-fdelete-null-pointer-checks" }
 
 #include <typeinfo>