Skip to content

fix(io): consider cpp2 line ending in comment #579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x: i32 = 0; // ugh
int main() { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@


//=== Cpp2 type declarations ====================================================


#include "cpp2util.h"



//=== Cpp2 type definitions and function declarations ===========================

#line 1 "mixed-bugfix-for-cpp2-comment-cpp1-sequence.cpp2"
extern cpp2::i32 x;
int main() { }
// ugh

//=== Cpp2 function definitions =================================================

#line 1 "mixed-bugfix-for-cpp2-comment-cpp1-sequence.cpp2"
cpp2::i32 x {0};

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mixed-bugfix-for-cpp2-comment-cpp1-sequence.cpp2... ok (mixed Cpp1/Cpp2, Cpp2 code passes safety checks)

4 changes: 2 additions & 2 deletions source/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ auto process_cpp_line(
}
}
}

break;case '\"':
// If this isn't an escaped quote, toggle string literal state
if (
Expand Down Expand Up @@ -746,7 +746,7 @@ auto process_cpp2_line(
}

break;case '/':
if (prev == '/') { in_comment = false; return false; }
if (prev == '/') { in_comment = false; return found_end; }

break;case '"':
if (prev != '\\') { in_string_literal = true; }
Expand Down