[hackers] [scc] [cc1] Fix function alike macro without arguments || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Tue, 5 Jul 2016 08:39:09 +0200 (CEST)

commit c50c0b5735d98f2503f99c215efae6c88c7a46c1
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Tue Jul 5 08:35:20 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Tue Jul 5 08:35:20 2016 +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.

diff --git a/cc1/cpp.c b/cc1/cpp.c
index 96e6404..3f572a8 100644
--- a/cc1/cpp.c
+++ b/cc1/cpp.c
_AT_@ -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
new file mode 100644
index 0000000..037bfe5
--- /dev/null
+++ b/cc1/tests/test064.c
_AT_@ -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();
+}
+
Received on Tue Jul 05 2016 - 08:39:09 CEST

This archive was generated by hypermail 2.3.0 : Tue Jul 05 2016 - 08:48:21 CEST