root/test/manual/cedet/tests/test.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. dont_show_function
  2. fun0
  3. fun1
  4. fun1p1
  5. fun2
  6. fun3
  7. fun4
  8. fun5
  9. funk1
  10. funk2
  11. funk3
  12. funk4_fixme

     1 /* test.c --- Semantic unit test for C.
     2 
     3    Copyright (C) 2001-2023 Free Software Foundation, Inc.
     4 
     5    Author: Eric M. Ludlam <zappo@gnu.org>
     6 
     7    This file is part of GNU Emacs.
     8 
     9    GNU Emacs is free software: you can redistribute it and/or modify
    10    it under the terms of the GNU General Public License as published by
    11    the Free Software Foundation, either version 3 of the License, or
    12    (at your option) any later version.
    13 
    14    GNU Emacs is distributed in the hope that it will be useful,
    15    but WITHOUT ANY WARRANTY; without even the implied warranty of
    16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17    GNU General Public License for more details.
    18 
    19    You should have received a copy of the GNU General Public License
    20    along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
    21 */
    22 
    23 /* Attempt to include as many aspects of the C language as possible.
    24  */
    25 
    26 /* types of include files */
    27 #include "includeme1.h"
    28 #include <includeme2.h>
    29 #include <subdir/includeme3.h>
    30 #include <includeme.notanhfile>
    31 #include <stdlib.h>
    32 #include <cmath>
    33 
    34 #if 0
    35 int dont_show_function()
    36 {
    37 }
    38 #endif
    39 
    40 /* Global types */
    41 struct mystruct1 {
    42   int slot11;
    43   char slot12;
    44   float slot13;
    45 };
    46 
    47 struct mystruct2 {
    48   int slot21;
    49   char slot22;
    50   float slot23;
    51 } var_of_type_mystruct2;
    52 
    53 struct {
    54   int slot31;
    55   char slot32;
    56   float slot33;
    57 } var_of_anonymous_struct;
    58 
    59 typedef struct mystruct1 typedef_of_mystruct1;
    60 typedef struct mystruct1 *typedef_of_pointer_mystruct1;
    61 typedef struct { int slot_a; } typedef_of_anonymous_struct;
    62 typedef struct A {
    63 } B;
    64 
    65 typedef struct mystruct1 td1, td2;
    66 
    67 union myunion1 {
    68   int slot41;
    69   char slot42;
    70   float slot43;
    71 };
    72 
    73 union myunion2 {
    74   int slot51;
    75   char slot52;
    76   float slot53;
    77 } var_of_type_myunion2;
    78 
    79 struct {
    80   int slot61;
    81   char slot72;
    82   float slot83;
    83 } var_of_anonymous_union;
    84 
    85 typedef union myunion1 typedef_of_myunion1;
    86 typedef union myunion1 *typedef_of_pointer_myunion1;
    87 typedef union { int slot_a; } typedef_of_anonymous_union;
    88 
    89 enum myenum1 { enum11 = 1, enum12 };
    90 enum myenum2 { enum21, enum22 = 2 } var_of_type_myenum2;
    91 enum { enum31, enum32 } var_of_anonymous_enum;
    92 
    93 typedef enum myenum1 typedef_of_myenum1;
    94 typedef enum myenum1 *typedef_of_pointer_myenum1;
    95 typedef enum { enum_a = 3, enum_b } typedef_of_anonymous_enum;
    96 
    97 typedef int typedef_of_int;
    98 
    99 /* Here are some simpler variable types */
   100 int var1;
   101 int varbit1:1;
   102 char var2;
   103 float var3;
   104 mystruct1 var3;
   105 struct mystruct1 var4;
   106 union myunion1 var5;
   107 enum myenum1 var6;
   108 
   109 char *varp1;
   110 char **varp2;
   111 char varv1[1];
   112 char varv2[1][2];
   113 
   114 char *varpa1 = "moose";
   115 struct mystruct2 vara2 = { 1, 'a', 0.0 };
   116 enum myenum1 vara3 = enum11;
   117 int vara4 = (int)0.0;
   118 int vara5 = funcall();
   119 
   120 int mvar1, mvar2, mvar3;
   121 char *mvarp1, *mvarp2, *mvarp3;
   122 char *mvarpa1 = 'a', *mvarpa2 = 'b', *mvarpa3 = 'c';
   123 char mvaras1[10], mvaras2[12][13], *mvaras3 = 'd';
   124 
   125 static register const unsigned int tmvar1;
   126 
   127 #define MACRO1 1
   128 #define MACRO2(foo) (1+foo)
   129 
   130 /* Here are some function prototypes */
   131 
   132 /* This is legal, but I decided not to support inferred integer
   133  * types on functions and variables.
   134  */
   135 fun0();
   136 int funp1();
   137 char funp2(int arg11);
   138 float funp3(char arg21, char arg22);
   139 struct mystrct1 funp4(struct mystruct2 arg31, union myunion2 arg32);
   140 enum myenum1 funp5(char *arg41, union myunion1 *arg42);
   141 
   142 char funpp1 __P(char argp1, struct mystruct2 argp2, char *arg4p);
   143 
   144 int fun1();
   145 
   146 /* Here is a function pointer */
   147 int (*funcptr)(int a, int b);
   148 
   149 /* Function Definitions */
   150 
   151 /* This is legal, but I decided not to support inferred integer
   152  * types on functions and variables.
   153  */
   154 fun0()
   155 {
   156   int sv = 0;
   157 }
   158 
   159 int fun1 ()
   160 {
   161   int sv = 1;
   162 }
   163 
   164 int fun1p1 (void)
   165 {
   166   int sv = 1;
   167 }
   168 
   169 char fun2(int arg_11)
   170 {
   171   char sv = 2;
   172 }
   173 
   174 float fun3(char arg_21, char arg_22)
   175 {
   176   char sv = 3;
   177 }
   178 
   179 struct mystrct1 fun4(struct mystruct2 arg31, union myunion2 arg32)
   180 {
   181   sv = 4;
   182 }
   183 
   184 enum myenum1 fun5(char *arg41, union myunion1 *arg42)
   185 {
   186   sv = 5;
   187 }
   188 
   189 /* Functions with K&R syntax. */
   190 struct mystrct1 funk1(arg_31, arg_32)
   191      struct mystruct2 arg_31;
   192      union myunion2 arg32;
   193 {
   194   sv = 4;
   195 }
   196 
   197 enum myenum1 *funk2(arg_41, arg_42)
   198      char *arg_41;
   199      union myunion1 *arg_42;
   200 {
   201   sv = 5;
   202 
   203   if(foo) {
   204   }
   205 }
   206 
   207 int funk3(arg_51, arg_53)
   208      int arg_51;
   209      char arg_53;
   210 {
   211   char q = 'a';
   212   int sv = 6;
   213   td1 ms1;
   214   enum myenum1 testconst;
   215 
   216   /* Function argument analysis */
   217   funk3(ms1.slot11, arg_53 );
   218   sv = 7;
   219 
   220   /* Slot deref on assignee */
   221   ms1.slot11 = s;
   222 
   223   /* Enum/const completion */
   224   testconst = e;
   225 
   226   /* Bad var/slot and param */
   227   blah.notafunction(moose);
   228 
   229   /* Print something. */
   230   printf("Moose", );
   231 
   232   tan();
   233 }
   234 
   235 int funk4_fixme(arg_61, arg_62)
   236      int arg_61, arg_62;
   237 {
   238 
   239 }
   240 
   241 /* End of C tests */

/* [<][>][^][v][top][bottom][index][help] */