File: prn3.cc

package info (click to toggle)
cccc 1%3A3.1.4-11
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,984 kB
  • sloc: ansic: 33,244; cpp: 10,527; java: 622; makefile: 158; sh: 11
file content (167 lines) | stat: -rw-r--r-- 3,012 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*
 From: 
       Ruppert <ru@swb.siemens.de>
 Reply-To: 
       Ruppert <ru@swb.siemens.de>
 To: 
       tim_littlefair@hotmail.com Save Address
 CC: 
       ru@swb.siemens.de Save Address
 Subject: 
       cccc-3.pre39: Parser errors
 Date: 
       Tue, 23 May 2000 09:23:16 +0200 (MET DST)
Hi,

I have just played around a bit with cccc-3.pre39 and tried
to analyze a large body of C++ code with it. It worked quite
well, and the results look quite useful.

The parser emits, however, a number of syntax errors, which I could
track to a few specific code constructs. These constructs are
legal C/C++, but the cccc parser generates "syntax error" messages.

I have stripped down the problems to the constructs in question;
I enclose a small test program which exhibits all of them. I hope
this is useful for fixing this.


Best Regards
Dr. D.Ruppert
RTS GmbH
Schwieberdingen/Germany
ru@swb.siemens.de

*/


/*
  Problem with inline attribute in class header:

  Processing test.cc as C/C++ (c++.ansi)
  test.cc(9) syntax error at token inline
  Parser context:
  test.cc(9): trying to match class_block_item_list at 'inline
  */

class InlFunc
{
  public:
    InlFunc();
    ~InlFunc();
    inline getFunc();
};



/*
  Problem with Initialization by function invoc. at file scope:

  Processing test.cc as C/C++ (c++.ansi)
  test.cc(2) syntax error at token (
  Parser context:
  test.cc(2): trying to match instance_declaration at 'const
  */

static const double d = sqrt(1.0 / 0.003);

/*
  Problem with function pointer as class member:
  test.cc(6) syntax error at token int
  Parser context:
  test.cc(6): trying to match class_block_item_list at 'int
  */


int getInt();
class FP
{
  public:
    int (*getInt)();
};



/*
  Problem with anonymous struct type:
  test.cc(5) syntax error at token struct
  Parser context:
  test.cc(5): trying to match class_block_item_list at 'struct
  */


struct A
{
    int a;
    struct
    {
        double d;
        float e;
    } myS;
};




/*
  Problem with / in initializer for int:
  Processing test.cc as C/C++ (c++.ansi)
  test.cc(1) syntax error at token /
  Parser context:
  test.cc(1): trying to match instance_declaration at 'const
  */


const int myInt = 10 / 4;

/*
  Problem with literal 0. in float-Initializer:

   invalid token near line 2 (text was '0.')
   test.cc(2) syntax error at token ;
   */
float f = 0. ;

/*
  Problem with anonymous union:

  Processing test.cc as C/C++ (c++.ansi)
  test.cc(6) syntax error at token union
  Parser context:
  test.cc(6): trying to match class_block_item_list at 'union
  */

class Hugo_2
{
  public:
    Hugo_2();
    ~Hugo_2();
    union
    {
        int a;
        double b;
    };
};

/*
  Problem with anonymous enum:

  Processing test.cc as C/C++ (c++.ansi)
  test.cc(7) syntax error at token enum
  Parser context:
  test.cc(7): trying to match class_block_item_list at 'enum
  ...
  */

class Hugo
{
  public:
    Hugo();
    ~Hugo();
    enum
    {
        START,
        STOP
    };
};