C: Fix line continuation handling (#1370)

Escaped newlines were properly handled inside preprocessor directives,
but not otherwise.

Seeing `continue` here suggests the code used to work a long time ago
but some loop refactoring broke it, as now it would not stay in the
loop unless in a preprocessor directive.  Or maybe it only ever worked
for preprocessor directives, and the `continue` was superfluous?

Fixes #1370.
This commit is contained in:
Colomban Wendling 2017-04-20 08:57:02 +02:00 committed by elextr
parent 2707006286
commit 6f692112e3
4 changed files with 46 additions and 1 deletions

View File

@ -704,7 +704,10 @@ process:
int next = getcFromInputFile (); int next = getcFromInputFile ();
if (next == NEWLINE) if (next == NEWLINE)
continue; {
c = getcFromInputFile ();
goto process;
}
else else
ungetcToInputFile (next); ungetcToInputFile (next);
break; break;

View File

@ -20,6 +20,7 @@ test_sources = \
array-spec.f90 \ array-spec.f90 \
attributes.cs \ attributes.cs \
auto.f \ auto.f \
backslashes.c \
bit_field.c \ bit_field.c \
block.f90 \ block.f90 \
bracematch.js \ bracematch.js \

29
tests/ctags/backslashes.c Normal file
View File

@ -0,0 +1,29 @@
typedef int T;
int func1(\
int var1, int var2, ...);
int func2(int var1, \
int var2, ...);
int func3(T \
var1, T var2, ...);
int func4(T var1, \
T var2, ...);
int func5(int \
var1, int var2, ...);
// check continuations in macros are properly handled
#define MACRO1 \
(
int func6(void);
#define MACRO2(x) \
int x(void);
#define MACRO3(y) \
int \
y \
( \
void \
);
int func7(int a);

View File

@ -0,0 +1,12 @@
# format=tagmanager
MACRO1Ì65536Ö0
MACRO2Ì131072Í(x)Ö0
MACRO3Ì131072Í(y)Ö0
TÌ4096Ö0Ïint
func1Ì1024Í(int var1, int var2, ...)Ö0Ïint
func2Ì1024Í(int var1, int var2, ...)Ö0Ïint
func3Ì1024Í(T var1, T var2, ...)Ö0Ïint
func4Ì1024Í(T var1, T var2, ...)Ö0Ïint
func5Ì1024Í(int var1, int var2, ...)Ö0Ïint
func6Ì1024Í(void)Ö0Ïint
func7Ì1024Í(int a)Ö0Ïint