From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by sourceware.org (Postfix) with ESMTP id 20D3D3851C19 for ; Wed, 24 Jun 2020 22:31:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 20D3D3851C19 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-14-B8WHL0QyOGKZwtQaxn9mRg-1; Wed, 24 Jun 2020 18:31:00 -0400 X-MC-Unique: B8WHL0QyOGKZwtQaxn9mRg-1 Received: by mail-wr1-f70.google.com with SMTP id j5so4569413wro.6 for ; Wed, 24 Jun 2020 15:31:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Gv5h/FQVeW7yRdkqscqVtllBv8bnUVhp83/PExEmw0A=; b=Be6AnTwVHQ/cAHZuDBEutTHpFllQVTFb7yO81CjhDOmDzTX94Rm9rwwcfZn99uyNAf O1oCc89Acmw2Az0sr01r7vcgG0oWboEWLCoHlAiyh4gL3ySJ4T4KPaWANT1IQnFjBEqi Yyl1WsnAtxf0UOa1J7YkYvJTkWVpZJu7D9OPp1p8QLKeCMrTFv0yfleAPjZ+zfeFJGy1 3VJLMu/igrBW6VDCHTt/1N6DWiWmpdqtWF0DOrHfEOxaGiX1JEDa1RvN22NNJr7UudaN /HvVomEg/SoBtr8IwlcX4yOtgPaz40roPrIugmvO5lwRTO5G4QvPvCQTMbxZ1kB7Aj2I 46vw== X-Gm-Message-State: AOAM5322tNR+TT82nAaj+2eIpceH6le4bBMAs/bJ52D7I5F7qIOxSVgQ 40XkEYKrHVygMvuC1x23JqDN/S1i+HDsHEVS/f38/3ML5QTe+X427zZbOVMSoWZ9FwSZaLS7HQV //l/pyUQNo2tquRPyfN8rHg== X-Received: by 2002:a1c:254:: with SMTP id 81mr31509516wmc.93.1593037859285; Wed, 24 Jun 2020 15:30:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQMykFL/ekQBmv40BYg2Ckh+xjArwj9JRtQyyjd7+/H7F5vs1f98iXTQqdAS0/LMbGghyOnQ== X-Received: by 2002:a1c:254:: with SMTP id 81mr31509490wmc.93.1593037858905; Wed, 24 Jun 2020 15:30:58 -0700 (PDT) Received: from ?IPv6:2001:8a0:f922:c400:56ee:75ff:fe8d:232b? ([2001:8a0:f922:c400:56ee:75ff:fe8d:232b]) by smtp.gmail.com with ESMTPSA id y17sm30045836wrd.58.2020.06.24.15.30.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Jun 2020 15:30:58 -0700 (PDT) Subject: Re: [PATCH] W/ Clang, compile/link C++ test programs with "-x c++" To: Gary Benson References: <1590770634-26360-1-git-send-email-gbenson@redhat.com> <7b5505a6-68ac-fc94-a747-ffec3c7bf086@redhat.com> <20200619134946.GA31823@blade.nx> <50b54268-e8aa-9ad6-1812-ec4647c1e3f3@redhat.com> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: Date: Wed, 24 Jun 2020 23:30:55 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <50b54268-e8aa-9ad6-1812-ec4647c1e3f3@redhat.com> Content-Language: en-US X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Jun 2020 22:31:04 -0000 On 6/19/20 4:42 PM, Pedro Alves via Gdb-patches wrote: > The patch below works for me with gdb.compile/compile-cplus.exp, and > also fixes gdb.base/whatis-ptype-typedefs.exp too at least. I've not run > the whole testsuite. I've run the whole testsuite now, and only gdb.arch/amd64-entry-value-paramref.exp had a similar issue with compiling an .S file as C++. Fixed in the version below, which I've now pushed. This makes these testcases compile and start running, at least: gdb.base/info-types-c++.exp gdb.base/max-depth-c++.exp gdb.base/msym-lang.exp gdb.base/whatis-ptype-typedefs.exp gdb.btrace/rn-dl-bind.exp From: Pedro Alves Date: 2020-06-24 23:18:19 +0100 W/ Clang, compile/link C++ test programs with "-x c++" Some testcases want to compile .c files with a C++ compiler. So they pass the "c++" option to gdb_compile. That works fine with GCC, but with Clang, it results in: gdb compile failed, clang-5.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated] and the testcase is skipped with UNTESTED. A previous patch fixed a case like that in gdb.compile/compile-cplus.exp, by adding -Wno-deprecated to the build options. However, there are other testcases that use the same pattern, and all fail for the same reason. For example: gdb.base/info-types-c++.exp gdb.base/max-depth-c++.exp gdb.base/msym-lang.exp gdb.base/whatis-ptype-typedefs.exp gdb.btrace/rn-dl-bind.exp Fix this in a central place, within gdb_compile, by passing "-x c++" to the compiler driver when we're compiling/linking C++. This revealed that gdb.compile/compile-cplus.exp and gdb.arch/amd64-entry-value-paramref.exp tests are compiling an assembly file with the "c++" option, which would now fail to compile, with the C++ compiler not grokking the assembly, of course. We just need to not pass "c++" and all the other related C++ options when compiling an assembly file. gdb/testsuite/ChangeLog: 2020-06-24 Pedro Alves * gdb.arch/amd64-entry-value-paramref.exp: Use prepare_for_testing_full and don't pass "c++" for the .S file build spec. * gdb.compile/compile-cplus.exp: Don't compile $srcfile3 with $options, since it's an assembly file. Remove -Wno-deprecated. * lib/gdb.exp (gdb_compile): Pass "-x c++" explicitly when compiling C++ programs. --- gdb/testsuite/ChangeLog | 10 ++++++++++ .../gdb.arch/amd64-entry-value-paramref.exp | 3 ++- gdb/testsuite/gdb.compile/compile-cplus.exp | 12 +----------- gdb/testsuite/lib/gdb.exp | 8 ++++++++ 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 6f4d99d3902..1b77459bce3 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2020-06-24 Pedro Alves + + * gdb.arch/amd64-entry-value-paramref.exp: Use + prepare_for_testing_full and don't pass "c++" for the .S file + build spec. + * gdb.compile/compile-cplus.exp: Don't compile $srcfile3 with + $options, since it's an assembly file. Remove -Wno-deprecated. + * lib/gdb.exp (gdb_compile): Pass "-x c++" explicitly when + compiling C++ programs. + 2020-06-24 Pedro Alves * lib/gdb.exp (gdb_compile): Update intro comment. If C/C++ with diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value-paramref.exp b/gdb/testsuite/gdb.arch/amd64-entry-value-paramref.exp index be60e2554d7..cbb69f46b81 100644 --- a/gdb/testsuite/gdb.arch/amd64-entry-value-paramref.exp +++ b/gdb/testsuite/gdb.arch/amd64-entry-value-paramref.exp @@ -20,7 +20,8 @@ if { ![istarget x86_64-*-* ] || ![is_lp64_target] } { return } -if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} "c++"] } { +if { [prepare_for_testing_full "failed to prepare" \ + [list $testfile "c++" $srcfile {}]] } { return -1 } diff --git a/gdb/testsuite/gdb.compile/compile-cplus.exp b/gdb/testsuite/gdb.compile/compile-cplus.exp index 85b2f20a8fa..f794e5a1439 100644 --- a/gdb/testsuite/gdb.compile/compile-cplus.exp +++ b/gdb/testsuite/gdb.compile/compile-cplus.exp @@ -24,11 +24,6 @@ if { [test_compiler_info gcc*] || [test_compiler_info clang*] } { lappend options additional_flags=-std=gnu++11 lappend options c++ } -if [test_compiler_info clang*] { - # Treating C input as C++ is deprecated in Clang, so - # the build will fail without disabling -Wdeprecated. - lappend options additional_flags=-Wno-deprecated -} if { ![istarget x86_64-*-* ] || ![is_lp64_target] } { verbose "Skipping x86_64 LOC_CONST test." @@ -37,14 +32,9 @@ if { ![istarget x86_64-*-* ] || ![is_lp64_target] } { set srcfilesoptions [list ${srcfile} ${options}] if { $srcfile3 != "" } { - lappend srcfilesoptions $srcfile3 ${options} + lappend srcfilesoptions $srcfile3 {} } set srcfile4options "nodebug c++" -if [test_compiler_info clang*] { - # Treating C input as C++ is deprecated in Clang, so - # the build will fail without disabling -Wdeprecated. - set srcfile4options "$srcfile4options additional_flags=-Wno-deprecated" -} lappend srcfilesoptions $srcfile4 $srcfile4options if { [eval build_executable_from_specs ${testfile}.exp $testfile {$options} ${srcfilesoptions}] } { return -1 diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 6b4f71be588..8dbfa7e7a94 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -3868,6 +3868,14 @@ proc gdb_compile {source dest type options} { lappend new_options "additional_flags=-Wno-unknown-warning-option" } + # Treating .c input files as C++ is deprecated in Clang, so + # explicitly force C++ language. + if { [lsearch -exact $options getting_compiler_info] == -1 + && [lsearch -exact $options c++] != -1 + && [test_compiler_info "clang-*"]} { + lappend new_options additional_flags=-x\ c++ + } + # Place (and look for) Fortran `.mod` files in the output # directory for this specific test. if {[lsearch -exact $options f77] != -1 \