commit c50c0b5735d98f2503f99c215efae6c88c7a46c1
parent 43dd1d697192c9831ef353f9932884f88c0e6f4c
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Tue, 5 Jul 2016 08:35:20 +0200
[cc1] Fix function alike macro without arguments
This case was not tested and there was an error parsing
this case, because we were checking yytoken, but in
this case we are still in '(', because cpp.c:parameter
pass to the next token before checking.
Diffstat:
2 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/cc1/cpp.c b/cc1/cpp.c
@@ -163,7 +163,9 @@ parsepars(char *buffer, char **listp, int nargs)
n = 0;
argp = buffer;
arglen = INPUTSIZ;
- if (yytoken != ')') {
+ if (ahead() == ')') {
+ next();
+ } else {
do {
*listp++ = argp;
parameter();
diff --git a/cc1/tests/test064.c b/cc1/tests/test064.c
@@ -0,0 +1,32 @@
+/* See LICENSE file for copyright and license details. */
+
+/*
+name: TEST064
+description: Test function alike macro without parenthesis
+error:
+output:
+G5 I F "main
+{
+\
+S1 " #N2 #N1
+M2 I "f #N0
+A6 S1 "s
+ A6 M2 .I #I0 :I
+ h A6 M2 .I
+}
+*/
+
+#define x f
+#define y() f
+
+typedef struct { int f; } S;
+
+int
+main()
+{
+ S s;
+
+ s.x = 0;
+ return s.y();
+}
+