From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id D263D3858D35 for ; Tue, 1 Feb 2022 09:04:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D263D3858D35 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-571-eddF7Zo-NAq89XhAcRMyHA-1; Tue, 01 Feb 2022 04:04:07 -0500 X-MC-Unique: eddF7Zo-NAq89XhAcRMyHA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D434F8143EA; Tue, 1 Feb 2022 09:04:05 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0D46678D85; Tue, 1 Feb 2022 09:04:00 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 21193wQc3078322 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 1 Feb 2022 10:03:58 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 21193v7n3078321; Tue, 1 Feb 2022 10:03:57 +0100 Date: Tue, 1 Feb 2022 10:03:57 +0100 From: Jakub Jelinek To: Jason Merrill , Marek Polacek , gcc-patches@gcc.gnu.org, "Joseph S. Myers" Subject: Re: [PATCH] libcpp: Fix up padding handling in funlike_invocation_p [PR104147] Message-ID: <20220201090357.GS2646553@tucnak> Reply-To: Jakub Jelinek References: <20220131190349.GM2646553@tucnak> <20220131232857.GO2646553@tucnak> MIME-Version: 1.0 In-Reply-To: <20220131232857.GO2646553@tucnak> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Feb 2022 09:04:13 -0000 On Tue, Feb 01, 2022 at 12:28:57AM +0100, Jakub Jelinek via Gcc-patches wrote: > I haven't, but will do so now. So, I've done another bootstrap/regtest with incremental --- gcc/c-family/c-lex.cc.jj 2022-01-18 00:18:02.558747051 +0100 +++ gcc/c-family/c-lex.cc 2022-02-01 00:39:47.314183266 +0100 @@ -297,6 +297,7 @@ get_token_no_padding (cpp_reader *pfile) ret = cpp_get_token (pfile); if (ret->type != CPP_PADDING) return ret; + gcc_assert ((ret->flags & PREV_WHITE) == 0); } } @@ -487,6 +488,7 @@ c_lex_with_flags (tree *value, location_ switch (type) { case CPP_PADDING: + gcc_assert ((tok->flags & PREV_WHITE) == 0); goto retry; case CPP_NAME: @@ -1267,6 +1269,7 @@ lex_string (const cpp_token *tok, tree * switch (tok->type) { case CPP_PADDING: + gcc_assert ((tok->flags & PREV_WHITE) == 0); goto retry; case CPP_ATSIGN: if (objc_string) --- libcpp/macro.cc.jj 2022-01-31 22:11:34.000000000 +0100 +++ libcpp/macro.cc 2022-02-01 00:28:30.717339868 +0100 @@ -1373,6 +1373,7 @@ funlike_invocation_p (cpp_reader *pfile, token = cpp_get_token (pfile); if (token->type != CPP_PADDING) break; + gcc_assert ((token->flags & PREV_WHITE) == 0); if (padding == NULL || padding->val.source == NULL || (!(padding->val.source->flags & PREV_WHITE) patch. The funlike_invocation_p macro never triggered, the other asserts did on some tests, see below for a full list. This seems to be caused by #pragma/_Pragma handling. do_pragma does: pfile->directive_result.src_loc = pragma_token_virt_loc; pfile->directive_result.type = CPP_PRAGMA; pfile->directive_result.flags = pragma_token->flags; pfile->directive_result.val.pragma = p->u.ident; when it sees a pragma, while start_directive does: pfile->directive_result.type = CPP_PADDING; and so does _cpp_do__Pragma. Now, for #pragma lex.cc will just ignore directive_result if it has CPP_PADDING type: if (_cpp_handle_directive (pfile, result->flags & PREV_WHITE)) { if (pfile->directive_result.type == CPP_PADDING) continue; result = &pfile->directive_result; } but destringize_and_run does not: if (pfile->directive_result.type == CPP_PRAGMA) { ... } else { count = 1; toks = XNEW (cpp_token); toks[0] = pfile->directive_result; and from there it will copy type member of CPP_PADDING, but all the other members from the last CPP_PRAGMA before it. Small testcase for it with no option (at least no -fopenmp or -fopenmp-simd). #pragma GCC push_options #pragma GCC ignored "-Wformat" #pragma GCC pop_options void foo () { _Pragma ("omp simd") for (int i = 0; i < 64; i++) ; } I wonder if we shouldn't replace that toks[0] = pfile->directive_result; line with toks[0] = pfile->avoid_paste; or even replace those toks = XNEW (cpp_token); toks[0] = pfile->directive_result; lines with toks = &pfile->avoid_paste; (dunno how about the memory management whether something frees the tokens or not, but e.g. funlike_invocation_p certainly uses the same _cpp_push_token_context and pushes through that quite often &pfile->avoid_paste). +FAIL: 20_util/specialized_algorithms/pstl/uninitialized_construct.cc (test for excess errors) +FAIL: 20_util/specialized_algorithms/pstl/uninitialized_copy_move.cc (test for excess errors) +FAIL: 20_util/specialized_algorithms/pstl/uninitialized_fill_destroy.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_merge/inplace_merge.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_merge/merge.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_modifying_operations/copy_if.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_modifying_operations/copy_move.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_modifying_operations/fill.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_modifying_operations/generate.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_modifying_operations/is_partitioned.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_modifying_operations/partition.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_modifying_operations/partition_copy.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_modifying_operations/remove.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_modifying_operations/remove_copy.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_modifying_operations/replace.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_modifying_operations/replace_copy.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_modifying_operations/rotate.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_modifying_operations/rotate_copy.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_modifying_operations/swap_ranges.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_modifying_operations/transform_binary.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_modifying_operations/transform_unary.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_modifying_operations/unique.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_modifying_operations/unique_copy_equal.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_nonmodifying/adjacent_find.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_nonmodifying/all_of.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_nonmodifying/any_of.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_nonmodifying/count.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_nonmodifying/equal.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_nonmodifying/find.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_nonmodifying/find_end.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_nonmodifying/find_first_of.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_nonmodifying/find_if.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_nonmodifying/for_each.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_nonmodifying/mismatch.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_nonmodifying/none_of.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_nonmodifying/nth_element.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_nonmodifying/reverse.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_nonmodifying/reverse_copy.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_nonmodifying/search_n.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_sorting/includes.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_sorting/is_heap.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_sorting/is_sorted.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_sorting/lexicographical_compare.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_sorting/minmax_element.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_sorting/partial_sort.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_sorting/partial_sort_copy.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_sorting/set.cc (test for excess errors) +FAIL: 25_algorithms/pstl/alg_sorting/sort.cc (test for excess errors) +FAIL: 26_numerics/pstl/numeric_ops/adjacent_difference.cc (test for excess errors) +FAIL: 26_numerics/pstl/numeric_ops/reduce.cc (test for excess errors) +FAIL: 26_numerics/pstl/numeric_ops/scan.cc (test for excess errors) +FAIL: 26_numerics/pstl/numeric_ops/transform_reduce.cc (test for excess errors) +FAIL: 26_numerics/pstl/numeric_ops/transform_scan.cc (test for excess errors) (+ corresponding UNRESOLVED). Jakub