From patchwork Tue Jan 21 22:00:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandra Loosemore X-Patchwork-Id: 1226779 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-517943-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=iQxalW6S; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 482MtW59C6z9sRX for ; Wed, 22 Jan 2020 09:01:05 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=OwfARyugLBbxGWz/hfJ39kzfC23JE2Ywm6ogksiu2o+di0NZ39 q0bgskg3QH2IUGLz3mVP5vnQidBC5Q8EIRd/iwl+yMfbImGsx1iyc6L3mlwe5qGc CZEmr4WqHkIbOmGNm+8JE4dYMCXo0VMZN3pmFqc4sH0WXE/mFs8OuL8Hs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=xuSkEq85NQYxRvtSA48a4TJGOXs=; b=iQxalW6SuFJeROi1Nlhw 2lL+HTdOGYEvX/9RFqefk1pd/oXq2DCyttz32CX3YOpR41VNVvn2Zv9lmcPYQdi7 +U1Qd+kHpxj05plfwA8RTUM6xKUX1Y1FSMJkUtGe2Y4g9UmvZpRR5Xyx7OVkV8Oc 80flXreoYTnENjvkz5bpyaY= Received: (qmail 31540 invoked by alias); 21 Jan 2020 22:00:55 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 31503 invoked by uid 89); 21 Jan 2020 22:00:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=troubling, new1.c, new2.C, new2c X-HELO: esa1.mentor.iphmx.com Received: from esa1.mentor.iphmx.com (HELO esa1.mentor.iphmx.com) (68.232.129.153) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 21 Jan 2020 22:00:42 +0000 IronPort-SDR: pYkNBkeNbHQDN4/RYJ7gM4TM73T0NYTbmBoMKxEYl+ngiGaYTkPvNAif7l2fXOA8DtBRs/bseP h+xolsGo1QcEUDZWUlPMre7fvSopftZvLeIQQRew22WRzucxdH9WbI2mNUUro0dH3nvGekiMhM 1LYBLLKBqDsdHtGiigOOvNQb5SxdqdbThOTeim0yujE+d54AqJzDQ0rB0ekxt36Cj2Fpb3Ehq5 2RIYKBeHA79Zkrpnss7E5qlWi5J6f/tbGXuDp+MHU5/b7NtJlHRNIu51ADZHXHOqrYDlNfG735 Mns= Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 21 Jan 2020 14:00:37 -0800 IronPort-SDR: CqiejNIIXk4bg5uH0AV+4MvdqKLHHsCaMM2ONKpLQqwoTyJ8B5FiV5mKcJn/yPvVbeP6BJAHMm /+fW/BIqm4ig== To: "gcc-patches@gcc.gnu.org" From: Sandra Loosemore Subject: [patch, testsuite] Add -fdelete-null-pointer-checks to some C++ testcases Message-ID: Date: Tue, 21 Jan 2020 15:00:30 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In doing some nios2-elf testing, I ran into a bunch of failures in constexpr-related tests in the C++ testsuite. This target defaults to -fno-delete-null-pointer-checks at the request of Altera/Intel, in order to support some of their BSPs where 0 is a legitimate memory address. Some other bare-metal targets also default to -fno-delete-null-pointer-checks. This patch makes the dependence of these tests on -fdelete-null-pointer-checks explicit. I've previously fixed some other tests that failed on nios2-elf in the same way so this is borderline obvious, but it's a little troubling to me that the correct semantics of some of these testcases seems to depend on what we document in the manual as an optimization option. :-S Maybe there is some other bug here? Anyway, if nobody has any objections or better ideas, I will go ahead and commit this in a few days. -Sandra diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-odr1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-odr1.C index cf3f95f..d00baae 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-odr1.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-odr1.C @@ -1,5 +1,6 @@ // PR c++/92062 - ODR-use ignored for static member of class template. // { dg-do run { target c++11 } } +// { dg-additional-options "-fdelete-null-pointer-checks" } template struct A { static const bool x; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-odr2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-odr2.C index 0927488..dd569a9 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-odr2.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-odr2.C @@ -1,5 +1,6 @@ // PR c++/92062 - ODR-use ignored for static member of class template. // { dg-do run { target c++11 } } +// { dg-additional-options "-fdelete-null-pointer-checks" } template struct A { static const bool x; diff --git a/gcc/testsuite/g++.dg/cpp0x/nontype4.C b/gcc/testsuite/g++.dg/cpp0x/nontype4.C index 2c552d0..b6a1ae7 100644 --- a/gcc/testsuite/g++.dg/cpp0x/nontype4.C +++ b/gcc/testsuite/g++.dg/cpp0x/nontype4.C @@ -1,5 +1,6 @@ // PR c++/56428 // { dg-do compile { target c++11 } } +// { dg-additional-options "-fdelete-null-pointer-checks" } struct A { }; diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-new.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-new.C index 6316ff2..d0ca0b7 100644 --- a/gcc/testsuite/g++.dg/cpp1y/constexpr-new.C +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-new.C @@ -1,4 +1,5 @@ // { dg-do compile { target c++14 } } +// { dg-additional-options "-fdelete-null-pointer-checks" } constexpr int *f4(bool b) { if (b) { diff --git a/gcc/testsuite/g++.dg/cpp1y/new1.C b/gcc/testsuite/g++.dg/cpp1y/new1.C index b9ad64d..7016951 100644 --- a/gcc/testsuite/g++.dg/cpp1y/new1.C +++ b/gcc/testsuite/g++.dg/cpp1y/new1.C @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O2 -fdump-tree-cddce-details" } */ +// { dg-additional-options "-fdelete-null-pointer-checks" } #include diff --git a/gcc/testsuite/g++.dg/cpp1y/new2.C b/gcc/testsuite/g++.dg/cpp1y/new2.C index 926e796..97f4001 100644 --- a/gcc/testsuite/g++.dg/cpp1y/new2.C +++ b/gcc/testsuite/g++.dg/cpp1y/new2.C @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O2 -std=c++17 -fdump-tree-cddce-details" } */ +/* { dg-additional-options "-fdelete-null-pointer-checks" } */ #include #include diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic11.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic11.C index 6069fbf..8dfa03a 100644 --- a/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic11.C +++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic11.C @@ -1,5 +1,6 @@ // PR c++/88337 - Implement P1327R1: Allow dynamic_cast/typeid in constexpr. // { dg-do compile { target c++2a } } +// { dg-additional-options "-fdelete-null-pointer-checks" } // dynamic_cast in a constructor. // [class.cdtor]#6: "If the operand of the dynamic_cast refers to the object diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic17.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic17.C index 6b443d2..c574e75 100644 --- a/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic17.C +++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic17.C @@ -1,5 +1,6 @@ // PR c++/88337 - Implement P1327R1: Allow dynamic_cast/typeid in constexpr. // { dg-do compile { target c++2a } } +// { dg-additional-options "-fdelete-null-pointer-checks" } // dynamic_cast in a constructor. // [class.cdtor]#6: "If the operand of the dynamic_cast refers to the object diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic4.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic4.C index 3adc524..6f42d20 100644 --- a/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic4.C +++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic4.C @@ -1,5 +1,6 @@ // PR c++/88337 - Implement P1327R1: Allow dynamic_cast/typeid in constexpr. // { dg-do compile { target c++2a } } +// { dg-additional-options "-fdelete-null-pointer-checks" } // From clang's constant-expression-cxx2a.cpp. diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-new1.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-new1.C index 873edd4..5d1b7ef 100644 --- a/gcc/testsuite/g++.dg/cpp2a/constexpr-new1.C +++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-new1.C @@ -1,5 +1,6 @@ // P0784R7 // { dg-do compile { target c++2a } } +// { dg-additional-options "-fdelete-null-pointer-checks" } struct S { constexpr S () : s (5) {} constexpr S (int x) : s (x) {} int s; }; diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-new10.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-new10.C index 500a324..bc5e6e5 100644 --- a/gcc/testsuite/g++.dg/cpp2a/constexpr-new10.C +++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-new10.C @@ -1,5 +1,6 @@ // PR c++/91369 // { dg-do compile { target c++2a } } +// { dg-additional-options "-fdelete-null-pointer-checks" } struct S { constexpr S (int* i) : s{i} {} diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-new2.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-new2.C index be54962..d3733e8 100644 --- a/gcc/testsuite/g++.dg/cpp2a/constexpr-new2.C +++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-new2.C @@ -1,5 +1,6 @@ // P0784R7 // { dg-do compile { target c++2a } } +// { dg-additional-options "-fdelete-null-pointer-checks" } template constexpr bool diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-new3.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-new3.C index 3380df7..6e7880a 100644 --- a/gcc/testsuite/g++.dg/cpp2a/constexpr-new3.C +++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-new3.C @@ -1,5 +1,6 @@ // P0784R7 // { dg-do compile { target c++2a } } +// { dg-additional-options "-fdelete-null-pointer-checks" } constexpr int * f1 () diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-new4.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-new4.C index 6cac983..b9bd5ea 100644 --- a/gcc/testsuite/g++.dg/cpp2a/constexpr-new4.C +++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-new4.C @@ -1,5 +1,6 @@ // P0784R7 // { dg-do compile { target c++2a } } +// { dg-additional-options "-fdelete-null-pointer-checks" } struct S { diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-new8.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-new8.C index c9c852d..f13da10 100644 --- a/gcc/testsuite/g++.dg/cpp2a/constexpr-new8.C +++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-new8.C @@ -1,5 +1,6 @@ // PR c++/91369 // { dg-do compile { target c++2a } } +// { dg-additional-options "-fdelete-null-pointer-checks" } struct A { constexpr A () : p{new int} {} diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-new9.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-new9.C index 552d3c1..f99f080 100644 --- a/gcc/testsuite/g++.dg/cpp2a/constexpr-new9.C +++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-new9.C @@ -1,5 +1,6 @@ // PR c++/91369 // { dg-do compile { target c++2a } } +// { dg-additional-options "-fdelete-null-pointer-checks" } struct S { constexpr S (int *i) : i{i} {} diff --git a/gcc/testsuite/g++.dg/cpp2a/nontype-class1.C b/gcc/testsuite/g++.dg/cpp2a/nontype-class1.C index 0c0b94d..a3334fc 100644 --- a/gcc/testsuite/g++.dg/cpp2a/nontype-class1.C +++ b/gcc/testsuite/g++.dg/cpp2a/nontype-class1.C @@ -1,4 +1,5 @@ // { dg-do compile { target c++2a } } +// { dg-additional-options "-fdelete-null-pointer-checks" } struct A {