From patchwork Tue Nov 5 16:58:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 1189849 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-512530-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="wi1XHnDY"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="W1r6OUpv"; 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 476wph00GHz9sPF for ; Wed, 6 Nov 2019 03:58:17 +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=DiuEgOya1E38dN+xRg6VhMd6tYsLlpBSINOMpCOWs2JzXS1glT 3E5tx2QUPXIHrFar5esVYIBej//2nfxPfIJA5N2Y5tRGlve7OWABwy0O8JdmcDP4 A1nYvTBQAVz4WqSaOJ4frzh3IBBRxpZMPTLyyfnw2bsUxzepnR1yLkne4= 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=O4IHUct3f7gWrrbeYspO56yZKZU=; b=wi1XHnDY0vaqIX5LwhF2 qflZ8HjJiqSQKrtWhlQpiqW1JXaTuD0z0Lxq/sDo3oEWqInsJPxPQPhmHmjSkCOf z0RLykMVFH+KoXd9aJXRckpna+I2Pt4mOOBRqUS1R28fTEdcu1U3kIUpaGryr2Gn 9FoCiwGwG38RwJbyyBo+ll8= Received: (qmail 89854 invoked by alias); 5 Nov 2019 16:58:11 -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 89843 invoked by uid 89); 5 Nov 2019 16:58:10 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=nathan@acm.org, U*nathan, cp_parser*, nathanacmorg X-HELO: mail-wr1-f42.google.com Received: from mail-wr1-f42.google.com (HELO mail-wr1-f42.google.com) (209.85.221.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 05 Nov 2019 16:58:09 +0000 Received: by mail-wr1-f42.google.com with SMTP id a15so22252486wrf.9 for ; Tue, 05 Nov 2019 08:58:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=kjpfDuinwSzkjwnL7KB58TKntz2FreUKM0i+NY2RjvM=; b=W1r6OUpvYh9TEjZeD3Jziv6Oi12hvBpu1ynNsNym49TU/Z7jynGcUymjHSTdXF4a8G X38SO6uT2QtkVeeSQrXRZZnj0yZmAoLEcRAjo7GCNakvC/Q6LMzVVSEhOFS2IZ6KINrm 5CwEBOsx90BjlsSrW51mDjCXCUTCOvZF6R/mBu88dWNW0mjNckpUJiQmWWzCdzXiCp9I 4atIOd+joICfTTr9ceg3bHUIis6A+Xrp+HcrRAlZ08FWF0kVHMxi8QKizT7i9bGnMuYS dh401bw+QmNIs3NhaJQ7W/sqE9MfSgXkkzdGAIzsCFo9GF2T/n45OnBeiWf5xzLrqrCE PiLQ== Received: from [10.133.164.83] ([109.144.223.168]) by smtp.googlemail.com with ESMTPSA id r3sm42716390wre.29.2019.11.05.08.58.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 Nov 2019 08:58:05 -0800 (PST) To: GCC Patches From: Nathan Sidwell Subject: [PR c++/92370] ICE with VC marker Message-ID: <20e0ada4-45db-c191-0e9b-738808afe9f7@acm.org> Date: Tue, 5 Nov 2019 16:58:00 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 This fixes 92370. cp_lexer_peek_token never returned NULL, so the check for that was always irrelevant. However, prior to my r277514 patch, eof caused us to point at the unique eof token, which had an UNKNOWN_LOCATION and hence we fell out of the loop. The lexer doesn't give the EOF token it returns a location corresponding to the beginning of the line at EOF (which seems wrong), but if it did, it wouldn't work if the VC marker occurred on the last line of a deferred parse buffer. thus we must check explicitly. Whilst there I realized this'd also break if we'd run out of locations and every token was UNKNOWN_LOCATION. Applying to trunk. nathan 2019-11-05 Nathan Sidwell cp/ PR c++/92370 * parser.c (cp_parser_error_1): Check EOF and UNKNOWN_LOCATION when skipping over version control marker. testsuite/ PR c++/92370 * g++.dg/pr92370.C: New. Index: gcc/cp/parser.c =================================================================== --- gcc/cp/parser.c (revision 277833) +++ gcc/cp/parser.c (working copy) @@ -2890,12 +2890,16 @@ cp_parser_error_1 (cp_parser* parser, co error_at (loc, "version control conflict marker in file"); expanded_location token_exploc = expand_location (token->location); /* Consume tokens until the end of the source line. */ - while (1) + for (;;) { cp_lexer_consume_token (parser->lexer); cp_token *next = cp_lexer_peek_token (parser->lexer); - if (next == NULL) + if (next->type == CPP_EOF) break; + if (next->location == UNKNOWN_LOCATION + || loc == UNKNOWN_LOCATION) + break; + expanded_location next_exploc = expand_location (next->location); if (next_exploc.file != token_exploc.file) break; Index: gcc/testsuite/g++.dg/pr92370.C =================================================================== --- gcc/testsuite/g++.dg/pr92370.C (nonexistent) +++ gcc/testsuite/g++.dg/pr92370.C (working copy) @@ -0,0 +1,3 @@ +// PR 92370 ICE with conlict marker + +<<<<<<<>>>>>>> // { dg-error "conflict marker" }