Home | History | Annotate | Line # | Download | only in lint1
decl_direct_abstract.c revision 1.1
      1 /*	$NetBSD: decl_direct_abstract.c,v 1.1 2021/09/13 22:09:06 rillig Exp $	*/
      2 # 3 "decl_direct_abstract.c"
      3 
      4 /*
      5  * Test parsing of direct-abstract-declarator (C99 6.7.6), which are a tricky
      6  * part of the C standard since they require lookahead and are so complicated
      7  * that GCC's parser dedicates 34 lines of comments to this topic.
      8  *
      9  * See msg_155.c.
     10  */
     11 
     12 /*
     13  * The following tests do not use int, to avoid confusion with the implicit
     14  * return type.
     15  */
     16 
     17 char func0001(short (*)(long));
     18 
     19 /* GCC says 'char (*)(short int (*)(long int))' */
     20 /* Clang says 'char (short (*)(long))' */
     21 /* cdecl says 'function (pointer to function (long) returning short) returning char' */
     22 /* expect+1: 'pointer to function(pointer to function(long) returning short) returning char' */
     23 double type_of_func0001 = func0001;
     24 
     25 char func0002(short *(long));
     26 
     27 /* GCC says 'char (*)(short int * (*)(long int))' */
     28 /* Clang says 'char (short *(*)(long))' */
     29 /* cdecl says 'syntax error' */
     30 /* FIXME: lint is wrong, it discards the 'short *' */
     31 /* expect+1: 'pointer to function(long) returning char' */
     32 double type_of_func0002 = func0002;
     33 
     34 void c99_6_7_6_example_a(int);
     35 void c99_6_7_6_example_b(int *);
     36 void c99_6_7_6_example_c(int *[3]);
     37 void c99_6_7_6_example_d(int (*)[3]);
     38 void c99_6_7_6_example_e(int (*)[*]);
     39 void c99_6_7_6_example_f(int *());
     40 void c99_6_7_6_example_g(int (*)(void));
     41 void c99_6_7_6_example_h(int (*const[])(unsigned int, ...));
     42 
     43 struct incompatible {
     44 	int member;
     45 } x;
     46 
     47 /* expect+1: 'pointer to function(int) returning void' */
     48 double type_of_c99_6_7_6_example_a = c99_6_7_6_example_a;
     49 /* expect+1: 'pointer to function(pointer to int) returning void' */
     50 double type_of_c99_6_7_6_example_b = c99_6_7_6_example_b;
     51 /* expect+1: 'pointer to function(pointer to pointer to int) returning void' */
     52 double type_of_c99_6_7_6_example_c = c99_6_7_6_example_c;
     53 /* expect+1: 'pointer to function(pointer to array[3] of int) returning void' */
     54 double type_of_c99_6_7_6_example_d = c99_6_7_6_example_d;
     55 /* expect+1: 'pointer to function(pointer to array[unknown_size] of int) returning void' */
     56 double type_of_c99_6_7_6_example_e = c99_6_7_6_example_e;
     57 /* FIXME: see msg_155.c, msg_347.c */
     58 /* expect+1: 'pointer to function(void) returning void' */
     59 double type_of_c99_6_7_6_example_f = c99_6_7_6_example_f;
     60 /* expect+1: 'pointer to function(pointer to function(void) returning int) returning void' */
     61 double type_of_c99_6_7_6_example_g = c99_6_7_6_example_g;
     62 /* expect+1: 'pointer to function(pointer to const pointer to function(unsigned int, ...) returning int) returning void' */
     63 double type_of_c99_6_7_6_example_h = c99_6_7_6_example_h;
     64