https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90630

            Bug ID: 90630
           Summary: missing error diagnosis of redundant parenthesis
           Product: gcc
           Version: 7.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tangyixuan at mail dot dlut.edu.cn
  Target Milestone: ---

GCC 4.3.0, 4.4.3, 6.1.0, and 7.1.0 do not report the error diagnosis when there
is a redundant parenthesis token in the following scenario, as well as several
other redundant tokens, such as ";",")","[", and etc..

For the following example, GCC 4.3.0, 4,4,3, 6.1.0, and 7.1.0 should report the
error diagnosis for line 2, such as "expected declaration specifiers or ‘...’
before ‘(’ token", to tell the token should be noticed, and help fix the error
in the code early.

$: cat s.c
 static long a
 static const int func_1((void);
 static const int func_1(void)
 { 
     return 0;
 }
 int main (int argc, char* argv[])
 {
     int a = func_1();
     return 0;
 }
$: gcc s.c
s.c:2:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before
‘static’
 static const int func_1((void);
 ^

version of GCC: 
gcc (Ubuntu 4.8.5-4ubuntu8~14.04.2) 4.3.0 or
gcc (Ubuntu 4.8.5-4ubuntu8~14.04.2) 4.4.3 or
gcc (Ubuntu 4.8.5-4ubuntu8~14.04.2) 6.1.0 or
gcc (Ubuntu 4.8.5-4ubuntu8~14.04.2) 7.1.0

Fortunately, when compiled with GCC 4.8.5, 8.1.0, and 8.2.0 under the same
workstation and the same command, there are error diagnoses of the redundant
token "(":
s.c:1:14: error:expected ‘;’ before ‘static’
 static long a
                      ^
                      ;
 static const int func_1((void);
 ~~~~~~        
s.c:2:25: error:expected declaration specifiers or ‘...’ before ‘(’ token
 static const int func_1((void);
                                         ^
In the same way, when compiled with Clang 6.0, 7.0, and 8.0, there are also
similar error diagnoses:
$clang s.c
s.c:1:14: error: expected ';' after top level declarator
static long a
                     ^
                     ;
s.c:2:31: error: expected ')'
static const int func_1((void);
                                                  ^

Reply via email to