Previously, the #pragma directive was swallowing an entire line, (including
the final newline). At that time it was appropriate for it to increment the
line count.
More recently, our handling of #pragma changed to not include the newline. But
the code to increment yylineno stuck around. This was causing __LINE__ to be
increased by one more than desired for every #pragma.
Remove the bogus, extra increment, and add a test for this case.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
* Simply pass them through to the main compiler's lexer/parser. */
<HASH>(extension|pragma)[^\r\n]* {
BEGIN INITIAL;
- yylineno++;
- yycolumn = 0;
RETURN_STRING_TOKEN (PRAGMA);
}
--- /dev/null
+Line 1 /* Test for a bug where #pragma was throwing off the __LINE__ count. */
+Line __LINE__ /* Line 2 */
+#pragma Line 3
+Line __LINE__ /* Line 4 */
+#pragma Line 5
+Line __LINE__ /* Line 6 */
--- /dev/null
+Line 1
+Line 2
+#pragma Line 3
+Line 4
+#pragma Line 5
+Line 6