aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/cc/lexer.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-11-03 14:56:31 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-11-03 14:56:31 +0200
commit6bd285316c4bceb38d5a7e5e9967cc84302056b4 (patch)
tree534fd589b16a560131b52355bd603205536a9cfb /libbuild2/cc/lexer.cxx
parent7c0629063ef64b6c7732e7ac94a6ecefcda4d828 (diff)
Generalize and export cc::lexer
Diffstat (limited to 'libbuild2/cc/lexer.cxx')
-rw-r--r--libbuild2/cc/lexer.cxx11
1 files changed, 7 insertions, 4 deletions
diff --git a/libbuild2/cc/lexer.cxx b/libbuild2/cc/lexer.cxx
index 467c0b1..96bd887 100644
--- a/libbuild2/cc/lexer.cxx
+++ b/libbuild2/cc/lexer.cxx
@@ -214,7 +214,7 @@ namespace build2
// #line <integer> [<string literal>] ...
// # <integer> [<string literal>] ...
//
- // Also diagnose #include while at it.
+ // Also diagnose #include while at it if preprocessed.
//
if (!(c >= '0' && c <= '9'))
{
@@ -222,10 +222,13 @@ namespace build2
if (t.type == type::identifier)
{
- if (t.value == "include")
- fail (l) << "unexpected #include directive";
- else if (t.value != "line")
+ if (t.value != "line")
+ {
+ if (preprocessed_ && t.value == "include")
+ fail (l) << "unexpected #include directive";
+
continue;
+ }
}
else
continue;