blob: 07d88b0cc9b87399009fa0452661561e357a4939 [file] [log] [blame]
Chris Lattnereb8a28f2006-08-10 18:43:39 +00001//===--- Declaration.cpp - Declaration Parsing ----------------------------===//
Chris Lattnerc0acd3d2006-07-31 05:13:43 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Chris Lattner and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the Declaration portions of the Parser interfaces.
11//
12//===----------------------------------------------------------------------===//
13
14#include "clang/Parse/Parser.h"
Chris Lattnerb9093cd2006-08-04 04:39:53 +000015#include "clang/Parse/Declarations.h"
Chris Lattnerc0acd3d2006-07-31 05:13:43 +000016using namespace llvm;
17using namespace clang;
18
19//===----------------------------------------------------------------------===//
20// C99 6.7: Declarations.
21//===----------------------------------------------------------------------===//
22
Chris Lattnerf5fbd792006-08-10 23:56:11 +000023/// ParseTypeName
24/// type-name: [C99 6.7.6]
25/// specifier-qualifier-list abstract-declarator[opt]
26void Parser::ParseTypeName() {
27 // Parse the common declaration-specifiers piece.
28 DeclSpec DS;
Chris Lattner1890ac82006-08-13 01:16:23 +000029 ParseSpecifierQualifierList(DS);
Chris Lattnerf5fbd792006-08-10 23:56:11 +000030
31 // Parse the abstract-declarator, if present.
32 Declarator DeclaratorInfo(DS, Declarator::TypeNameContext);
33 ParseDeclarator(DeclaratorInfo);
34}
35
36
Chris Lattner53361ac2006-08-10 05:19:57 +000037/// ParseDeclaration - Parse a full 'declaration', which consists of
38/// declaration-specifiers, some number of declarators, and a semicolon.
39/// 'Context' should be a Declarator::TheContext value.
40void Parser::ParseDeclaration(unsigned Context) {
41 // Parse the common declaration-specifiers piece.
42 DeclSpec DS;
43 ParseDeclarationSpecifiers(DS);
44
Chris Lattner0e894622006-08-13 19:58:17 +000045 // C99 6.7.2.3p6: Handle "struct-or-union identifier;", "enum { X };"
46 // declaration-specifiers init-declarator-list[opt] ';'
47 if (Tok.getKind() == tok::semi) {
48 // TODO: emit error on 'int;' or 'const enum foo;'.
49 // if (!DS.isMissingDeclaratorOk()) Diag(...);
50
51 ConsumeToken();
52 return;
53 }
54
Chris Lattner53361ac2006-08-10 05:19:57 +000055 Declarator DeclaratorInfo(DS, (Declarator::TheContext)Context);
56 ParseDeclarator(DeclaratorInfo);
57
58 ParseInitDeclaratorListAfterFirstDeclarator(DeclaratorInfo);
59}
60
61void Parser::ParseInitDeclaratorListAfterFirstDeclarator(Declarator &D) {
62 // At this point, we know that it is not a function definition. Parse the
63 // rest of the init-declarator-list.
64 while (1) {
65 // must be: decl-spec[opt] declarator init-declarator-list
66 // Parse declarator '=' initializer.
67 if (Tok.getKind() == tok::equal) {
68 ConsumeToken();
Chris Lattnerc5e0d4a2006-08-10 19:06:03 +000069 ParseInitializer();
Chris Lattner53361ac2006-08-10 05:19:57 +000070 }
71
Chris Lattner53361ac2006-08-10 05:19:57 +000072 // TODO: install declarator.
73
74 // If we don't have a comma, it is either the end of the list (a ';') or an
75 // error, bail out.
76 if (Tok.getKind() != tok::comma)
77 break;
78
79 // Consume the comma.
80 ConsumeToken();
81
82 // Parse the next declarator.
83 D.clear();
84 ParseDeclarator(D);
85 }
86
87 if (Tok.getKind() == tok::semi) {
88 ConsumeToken();
89 } else {
90 Diag(Tok, diag::err_parse_error);
91 // Skip to end of block or statement
92 SkipUntil(tok::r_brace, true);
93 if (Tok.getKind() == tok::semi)
94 ConsumeToken();
95 }
96}
97
Chris Lattner1890ac82006-08-13 01:16:23 +000098/// ParseSpecifierQualifierList
99/// specifier-qualifier-list:
100/// type-specifier specifier-qualifier-list[opt]
101/// type-qualifier specifier-qualifier-list[opt]
102///
103void Parser::ParseSpecifierQualifierList(DeclSpec &DS) {
104 /// specifier-qualifier-list is a subset of declaration-specifiers. Just
105 /// parse declaration-specifiers and complain about extra stuff.
106 SourceLocation Loc = Tok.getLocation();
107 ParseDeclarationSpecifiers(DS);
108
109 // Validate declspec for type-name.
110 unsigned Specs = DS.getParsedSpecifiers();
111 if (Specs == DeclSpec::PQ_None)
112 Diag(Tok, diag::err_typename_requires_specqual);
113
114 if (Specs & DeclSpec::PQ_StorageClassSpecifier) {
115 Diag(Loc, diag::err_typename_invalid_storageclass);
116 // Remove storage class.
117 DS.StorageClassSpec = DeclSpec::SCS_unspecified;
118 DS.SCS_thread_specified = false;
119 }
120 if (Specs & DeclSpec::PQ_FunctionSpecifier) {
121 Diag(Loc, diag::err_typename_invalid_functionspec);
122 DS.FS_inline_specified = false;
123 }
124}
Chris Lattner53361ac2006-08-10 05:19:57 +0000125
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000126/// ParseDeclarationSpecifiers
127/// declaration-specifiers: [C99 6.7]
Chris Lattner3b561a32006-08-13 00:12:11 +0000128/// storage-class-specifier declaration-specifiers[opt]
129/// type-specifier declaration-specifiers[opt]
130/// type-qualifier declaration-specifiers[opt]
131/// [C99] function-specifier declaration-specifiers[opt]
132/// [GNU] attributes declaration-specifiers[opt] [TODO]
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000133///
Chris Lattnerf63f89a2006-08-05 03:28:50 +0000134/// storage-class-specifier: [C99 6.7.1]
Chris Lattnerda48a8e2006-08-04 05:25:55 +0000135/// 'typedef'
136/// 'extern'
137/// 'static'
138/// 'auto'
139/// 'register'
140/// [GNU] '__thread'
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000141/// type-specifier: [C99 6.7.2]
142/// 'void'
143/// 'char'
144/// 'short'
145/// 'int'
146/// 'long'
147/// 'float'
148/// 'double'
149/// 'signed'
150/// 'unsigned'
Chris Lattner1890ac82006-08-13 01:16:23 +0000151/// struct-or-union-specifier
Chris Lattner3b561a32006-08-13 00:12:11 +0000152/// enum-specifier
Chris Lattner8e90ef62006-08-05 03:30:45 +0000153/// typedef-name [TODO]
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000154/// [C99] '_Bool'
155/// [C99] '_Complex'
Chris Lattnerda48a8e2006-08-04 05:25:55 +0000156/// [C99] '_Imaginary' // Removed in TC2?
157/// [GNU] '_Decimal32'
158/// [GNU] '_Decimal64'
159/// [GNU] '_Decimal128'
Chris Lattnerf63f89a2006-08-05 03:28:50 +0000160/// [GNU] typeof-specifier [TODO]
Chris Lattner3b561a32006-08-13 00:12:11 +0000161/// [OBJC] class-name objc-protocol-refs[opt] [TODO]
Chris Lattnerda48a8e2006-08-04 05:25:55 +0000162/// [OBJC] typedef-name objc-protocol-refs [TODO]
163/// [OBJC] objc-protocol-refs [TODO]
Chris Lattnerda48a8e2006-08-04 05:25:55 +0000164/// type-qualifier:
Chris Lattner3b561a32006-08-13 00:12:11 +0000165/// 'const'
166/// 'volatile'
167/// [C99] 'restrict'
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000168/// function-specifier: [C99 6.7.4]
Chris Lattner3b561a32006-08-13 00:12:11 +0000169/// [C99] 'inline'
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000170///
171void Parser::ParseDeclarationSpecifiers(DeclSpec &DS) {
172 SourceLocation StartLoc = Tok.getLocation();
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000173 while (1) {
Chris Lattnerda48a8e2006-08-04 05:25:55 +0000174 int isInvalid = false;
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000175 const char *PrevSpec = 0;
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000176 switch (Tok.getKind()) {
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000177 default:
178 // If this is not a declaration specifier token, we're done reading decl
179 // specifiers. First verify that DeclSpec's are consistent.
Chris Lattner839713c2006-08-04 06:15:52 +0000180 DS.Finish(StartLoc, Diags, getLang());
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000181 return;
Chris Lattnerf63f89a2006-08-05 03:28:50 +0000182
183 // storage-class-specifier
184 case tok::kw_typedef:
185 isInvalid = DS.SetStorageClassSpec(DeclSpec::SCS_typedef, PrevSpec);
186 break;
187 case tok::kw_extern:
188 if (DS.SCS_thread_specified)
189 Diag(Tok, diag::ext_thread_before, "extern");
190 isInvalid = DS.SetStorageClassSpec(DeclSpec::SCS_extern, PrevSpec);
191 break;
192 case tok::kw_static:
193 if (DS.SCS_thread_specified)
194 Diag(Tok, diag::ext_thread_before, "static");
195 isInvalid = DS.SetStorageClassSpec(DeclSpec::SCS_static, PrevSpec);
196 break;
197 case tok::kw_auto:
198 isInvalid = DS.SetStorageClassSpec(DeclSpec::SCS_auto, PrevSpec);
199 break;
200 case tok::kw_register:
201 isInvalid = DS.SetStorageClassSpec(DeclSpec::SCS_register, PrevSpec);
202 break;
203 case tok::kw___thread:
204 if (DS.SCS_thread_specified)
205 isInvalid = 2, PrevSpec = "__thread";
206 else
207 DS.SCS_thread_specified = true;
208 break;
209
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000210 // type-specifiers
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000211 case tok::kw_short:
212 isInvalid = DS.SetTypeSpecWidth(DeclSpec::TSW_short, PrevSpec);
213 break;
214 case tok::kw_long:
215 if (DS.TypeSpecWidth != DeclSpec::TSW_long) {
216 isInvalid = DS.SetTypeSpecWidth(DeclSpec::TSW_long, PrevSpec);
217 } else {
218 DS.TypeSpecWidth = DeclSpec::TSW_unspecified;
219 isInvalid = DS.SetTypeSpecWidth(DeclSpec::TSW_longlong, PrevSpec);
220 }
221 break;
222 case tok::kw_signed:
223 isInvalid = DS.SetTypeSpecSign(DeclSpec::TSS_signed, PrevSpec);
224 break;
225 case tok::kw_unsigned:
226 isInvalid = DS.SetTypeSpecSign(DeclSpec::TSS_unsigned, PrevSpec);
227 break;
228 case tok::kw__Complex:
229 isInvalid = DS.SetTypeSpecComplex(DeclSpec::TSC_complex, PrevSpec);
230 break;
231 case tok::kw__Imaginary:
232 isInvalid = DS.SetTypeSpecComplex(DeclSpec::TSC_imaginary, PrevSpec);
233 break;
234 case tok::kw_void:
235 isInvalid = DS.SetTypeSpecType(DeclSpec::TST_void, PrevSpec);
236 break;
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000237 case tok::kw_char:
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000238 isInvalid = DS.SetTypeSpecType(DeclSpec::TST_char, PrevSpec);
239 break;
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000240 case tok::kw_int:
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000241 isInvalid = DS.SetTypeSpecType(DeclSpec::TST_int, PrevSpec);
242 break;
243 case tok::kw_float:
244 isInvalid = DS.SetTypeSpecType(DeclSpec::TST_float, PrevSpec);
245 break;
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000246 case tok::kw_double:
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000247 isInvalid = DS.SetTypeSpecType(DeclSpec::TST_double, PrevSpec);
248 break;
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000249 case tok::kw__Bool:
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000250 isInvalid = DS.SetTypeSpecType(DeclSpec::TST_bool, PrevSpec);
251 break;
252 case tok::kw__Decimal32:
253 isInvalid = DS.SetTypeSpecType(DeclSpec::TST_decimal32, PrevSpec);
254 break;
255 case tok::kw__Decimal64:
256 isInvalid = DS.SetTypeSpecType(DeclSpec::TST_decimal64, PrevSpec);
257 break;
258 case tok::kw__Decimal128:
259 isInvalid = DS.SetTypeSpecType(DeclSpec::TST_decimal128, PrevSpec);
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000260 break;
261
Chris Lattner1890ac82006-08-13 01:16:23 +0000262 case tok::kw_struct:
263 case tok::kw_union:
264 ParseStructUnionSpecifier(DS);
265 continue;
Chris Lattner3b561a32006-08-13 00:12:11 +0000266 case tok::kw_enum:
267 ParseEnumSpecifier(DS);
268 continue;
Chris Lattnerda48a8e2006-08-04 05:25:55 +0000269
Chris Lattneracd58a32006-08-06 17:24:14 +0000270 //case tok::identifier:
271 // TODO: handle typedef names.
272
Chris Lattnerda48a8e2006-08-04 05:25:55 +0000273 // type-qualifier
274 case tok::kw_const:
275 isInvalid = DS.SetTypeQual(DeclSpec::TQ_const , PrevSpec, getLang())*2;
276 break;
277 case tok::kw_volatile:
278 isInvalid = DS.SetTypeQual(DeclSpec::TQ_volatile, PrevSpec, getLang())*2;
279 break;
280 case tok::kw_restrict:
281 isInvalid = DS.SetTypeQual(DeclSpec::TQ_restrict, PrevSpec, getLang())*2;
282 break;
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000283
284 // function-specifier
285 case tok::kw_inline:
Chris Lattnerf63f89a2006-08-05 03:28:50 +0000286 // 'inline inline' is ok.
287 DS.FS_inline_specified = true;
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000288 break;
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000289 }
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000290 // If the specifier combination wasn't legal, issue a diagnostic.
291 if (isInvalid) {
292 assert(PrevSpec && "Method did not return previous specifier!");
Chris Lattnerda48a8e2006-08-04 05:25:55 +0000293 if (isInvalid == 1) // Error.
294 Diag(Tok, diag::err_invalid_decl_spec_combination, PrevSpec);
295 else // extwarn.
296 Diag(Tok, diag::ext_duplicate_declspec, PrevSpec);
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000297 }
298 ConsumeToken();
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000299 }
300}
301
Chris Lattner1890ac82006-08-13 01:16:23 +0000302
303/// ParseStructUnionSpecifier
304/// struct-or-union-specifier: [C99 6.7.2.1]
305/// struct-or-union identifier[opt] '{' struct-declaration-list '}'
306/// struct-or-union identifier
307/// struct-or-union:
308/// 'struct'
309/// 'union'
310/// struct-declaration-list:
311/// struct-declaration
312/// struct-declaration-list struct-declaration
313/// struct-declaration:
314/// specifier-qualifier-list struct-declarator-list ';'
315/// struct-declarator-list:
316/// struct-declarator
317/// struct-declarator-list ',' struct-declarator
318/// struct-declarator:
319/// declarator
320/// declarator[opt] ':' constant-expression
321///
322void Parser::ParseStructUnionSpecifier(DeclSpec &DS) {
323 assert((Tok.getKind() == tok::kw_struct ||
324 Tok.getKind() == tok::kw_union) && "Not a struct/union specifier");
325 bool isUnion = Tok.getKind() == tok::kw_union;
326 ConsumeToken();
327
328 // Must have either 'struct name' or 'struct {...}'.
329 if (Tok.getKind() != tok::identifier &&
330 Tok.getKind() != tok::l_brace) {
331 Diag(Tok, diag::err_expected_ident_lbrace);
332 return;
333 }
334
335 if (Tok.getKind() == tok::identifier)
336 ConsumeToken();
337
338 if (Tok.getKind() != tok::l_brace)
339 return;
340
341 SourceLocation LBraceLoc = Tok.getLocation();
342 ConsumeBrace();
343
344 if (Tok.getKind() == tok::r_brace)
345 Diag(Tok, diag::ext_empty_struct_union_enum, isUnion ? "union" : "struct");
346
347 while (Tok.getKind() != tok::r_brace &&
348 Tok.getKind() != tok::eof) {
349 // Each iteration of this loop reads one struct-declaration.
350
351 // Parse the common specifier-qualifiers-list piece.
352 DeclSpec DS;
353 SourceLocation SpecQualLoc = Tok.getLocation();
354 ParseSpecifierQualifierList(DS);
355 // TODO: Does specifier-qualifier list correctly check that *something* is
356 // specified?
357
358 Declarator DeclaratorInfo(DS, Declarator::MemberContext);
359
360 // If there are no declarators, issue a warning.
361 if (Tok.getKind() == tok::semi) {
362 Diag(SpecQualLoc, diag::w_no_declarators);
363 } else {
364 // Read struct-declarators until we find the semicolon.
365 while (1) {
366 /// struct-declarator: declarator
367 /// struct-declarator: declarator[opt] ':' constant-expression
368 if (Tok.getKind() != tok::colon)
369 ParseDeclarator(DeclaratorInfo);
370
371 if (Tok.getKind() == tok::colon) {
372 ConsumeToken();
373 ExprResult Res = ParseConstantExpression();
374 if (Res.isInvalid) {
375 SkipUntil(tok::semi, true, true);
376 } else {
377 // Process it.
378 }
379 }
380
381 // TODO: install declarator.
382
383 // If we don't have a comma, it is either the end of the list (a ';') or
384 // an error, bail out.
385 if (Tok.getKind() != tok::comma)
386 break;
387
388 // Consume the comma.
389 ConsumeToken();
390
391 // Parse the next declarator.
392 DeclaratorInfo.clear();
393 }
394 }
395
396 if (Tok.getKind() == tok::semi) {
397 ConsumeToken();
398 } else {
399 Diag(Tok, diag::err_expected_semi_decl_list);
400 // Skip to end of block or statement
401 SkipUntil(tok::r_brace, true, true);
402 }
403 }
404
405 MatchRHSPunctuation(tok::r_brace, LBraceLoc, "{",diag::err_expected_rbrace);
406}
407
408
Chris Lattner3b561a32006-08-13 00:12:11 +0000409/// ParseEnumSpecifier
Chris Lattner1890ac82006-08-13 01:16:23 +0000410/// enum-specifier: [C99 6.7.2.2]
Chris Lattner3b561a32006-08-13 00:12:11 +0000411/// 'enum' identifier[opt] '{' enumerator-list '}'
412/// [C99] 'enum' identifier[opt] '{' enumerator-list ',' '}'
413/// 'enum' identifier
414/// enumerator-list:
415/// enumerator
Chris Lattner1890ac82006-08-13 01:16:23 +0000416/// enumerator-list ',' enumerator
Chris Lattner3b561a32006-08-13 00:12:11 +0000417/// enumerator:
418/// enumeration-constant
Chris Lattner1890ac82006-08-13 01:16:23 +0000419/// enumeration-constant '=' constant-expression
Chris Lattner3b561a32006-08-13 00:12:11 +0000420/// enumeration-constant:
421/// identifier
422///
423void Parser::ParseEnumSpecifier(DeclSpec &DS) {
424 assert(Tok.getKind() == tok::kw_enum && "Not an enum specifier");
425 ConsumeToken();
426
427 // Must have either 'enum name' or 'enum {...}'.
428 if (Tok.getKind() != tok::identifier &&
429 Tok.getKind() != tok::l_brace) {
430 Diag(Tok, diag::err_expected_ident_lbrace);
431 return;
432 }
433
434 if (Tok.getKind() == tok::identifier)
435 ConsumeToken();
436
Chris Lattner1890ac82006-08-13 01:16:23 +0000437 if (Tok.getKind() != tok::l_brace)
438 return;
439
440 SourceLocation LBraceLoc = Tok.getLocation();
441 ConsumeBrace();
442
443 if (Tok.getKind() == tok::r_brace)
444 Diag(Tok, diag::ext_empty_struct_union_enum, "enum");
445
446 // Parse the enumerator-list.
447 while (Tok.getKind() == tok::identifier) {
448 ConsumeToken();
Chris Lattner3b561a32006-08-13 00:12:11 +0000449
Chris Lattner1890ac82006-08-13 01:16:23 +0000450 if (Tok.getKind() == tok::equal) {
Chris Lattner3b561a32006-08-13 00:12:11 +0000451 ConsumeToken();
Chris Lattner1890ac82006-08-13 01:16:23 +0000452 ExprResult Res = ParseConstantExpression();
453 if (Res.isInvalid) SkipUntil(tok::comma, true, false);
Chris Lattner3b561a32006-08-13 00:12:11 +0000454 }
455
Chris Lattner1890ac82006-08-13 01:16:23 +0000456 if (Tok.getKind() != tok::comma)
457 break;
458 SourceLocation CommaLoc = Tok.getLocation();
459 ConsumeToken();
460
461 if (Tok.getKind() != tok::identifier && !getLang().C99)
462 Diag(CommaLoc, diag::ext_c99_enumerator_list_comma);
Chris Lattner3b561a32006-08-13 00:12:11 +0000463 }
Chris Lattner1890ac82006-08-13 01:16:23 +0000464
465 // Eat the }.
466 MatchRHSPunctuation(tok::r_brace, LBraceLoc, "{",
467 diag::err_expected_rbrace);
Chris Lattner3b561a32006-08-13 00:12:11 +0000468 // TODO: semantic analysis on the declspec for enums.
469}
470
471
Chris Lattnerf5fbd792006-08-10 23:56:11 +0000472/// isTypeSpecifierQualifier - Return true if the current token could be the
473/// start of a specifier-qualifier-list.
474bool Parser::isTypeSpecifierQualifier() const {
475 switch (Tok.getKind()) {
476 default: return false;
477 // type-specifiers
478 case tok::kw_short:
479 case tok::kw_long:
480 case tok::kw_signed:
481 case tok::kw_unsigned:
482 case tok::kw__Complex:
483 case tok::kw__Imaginary:
484 case tok::kw_void:
485 case tok::kw_char:
486 case tok::kw_int:
487 case tok::kw_float:
488 case tok::kw_double:
489 case tok::kw__Bool:
490 case tok::kw__Decimal32:
491 case tok::kw__Decimal64:
492 case tok::kw__Decimal128:
493
494 // struct-or-union-specifier
495 case tok::kw_struct:
496 case tok::kw_union:
497 // enum-specifier
498 case tok::kw_enum:
499
500 // type-qualifier
501 case tok::kw_const:
502 case tok::kw_volatile:
503 case tok::kw_restrict:
504 return true;
505
506 // typedef-name
507 case tok::identifier:
508 // FIXME: if this is a typedef return true.
509 return false;
510
511 // TODO: Attributes.
512 }
513}
514
Chris Lattneracd58a32006-08-06 17:24:14 +0000515/// isDeclarationSpecifier() - Return true if the current token is part of a
516/// declaration specifier.
517bool Parser::isDeclarationSpecifier() const {
518 switch (Tok.getKind()) {
519 default: return false;
520 // storage-class-specifier
521 case tok::kw_typedef:
522 case tok::kw_extern:
523 case tok::kw_static:
524 case tok::kw_auto:
525 case tok::kw_register:
526 case tok::kw___thread:
527
528 // type-specifiers
529 case tok::kw_short:
530 case tok::kw_long:
531 case tok::kw_signed:
532 case tok::kw_unsigned:
533 case tok::kw__Complex:
534 case tok::kw__Imaginary:
535 case tok::kw_void:
536 case tok::kw_char:
537 case tok::kw_int:
538 case tok::kw_float:
539 case tok::kw_double:
540 case tok::kw__Bool:
541 case tok::kw__Decimal32:
542 case tok::kw__Decimal64:
543 case tok::kw__Decimal128:
544
545 // struct-or-union-specifier
546 case tok::kw_struct:
547 case tok::kw_union:
548 // enum-specifier
549 case tok::kw_enum:
Chris Lattnerf5fbd792006-08-10 23:56:11 +0000550
Chris Lattneracd58a32006-08-06 17:24:14 +0000551 // type-qualifier
552 case tok::kw_const:
553 case tok::kw_volatile:
554 case tok::kw_restrict:
Chris Lattnerf5fbd792006-08-10 23:56:11 +0000555
Chris Lattneracd58a32006-08-06 17:24:14 +0000556 // function-specifier
557 case tok::kw_inline:
558 return true;
Chris Lattnerf5fbd792006-08-10 23:56:11 +0000559
Chris Lattneracd58a32006-08-06 17:24:14 +0000560 // typedef-name
561 case tok::identifier:
562 // FIXME: if this is a typedef return true.
563 return false;
564 // TODO: Attributes.
565 }
566}
567
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000568
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000569/// ParseTypeQualifierListOpt
570/// type-qualifier-list: [C99 6.7.5]
571/// type-qualifier
572/// [GNU] attributes [TODO]
573/// type-qualifier-list type-qualifier
574/// [GNU] type-qualifier-list attributes [TODO]
575///
Chris Lattnerd9c3c592006-08-05 06:26:47 +0000576void Parser::ParseTypeQualifierListOpt(DeclSpec &DS) {
577 SourceLocation StartLoc = Tok.getLocation();
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000578 while (1) {
Chris Lattnerd9c3c592006-08-05 06:26:47 +0000579 int isInvalid = false;
580 const char *PrevSpec = 0;
581
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000582 switch (Tok.getKind()) {
Chris Lattnerd9c3c592006-08-05 06:26:47 +0000583 default:
584 // If this is not a declaration specifier token, we're done reading decl
585 // specifiers. First verify that DeclSpec's are consistent.
586 DS.Finish(StartLoc, Diags, getLang());
587 return;
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000588 // TODO: attributes.
589 case tok::kw_const:
Chris Lattnerd9c3c592006-08-05 06:26:47 +0000590 isInvalid = DS.SetTypeQual(DeclSpec::TQ_const , PrevSpec, getLang())*2;
591 break;
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000592 case tok::kw_volatile:
Chris Lattnerd9c3c592006-08-05 06:26:47 +0000593 isInvalid = DS.SetTypeQual(DeclSpec::TQ_volatile, PrevSpec, getLang())*2;
594 break;
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000595 case tok::kw_restrict:
Chris Lattnerd9c3c592006-08-05 06:26:47 +0000596 isInvalid = DS.SetTypeQual(DeclSpec::TQ_restrict, PrevSpec, getLang())*2;
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000597 break;
598 }
Chris Lattnerd9c3c592006-08-05 06:26:47 +0000599
600 // If the specifier combination wasn't legal, issue a diagnostic.
601 if (isInvalid) {
602 assert(PrevSpec && "Method did not return previous specifier!");
603 if (isInvalid == 1) // Error.
604 Diag(Tok, diag::err_invalid_decl_spec_combination, PrevSpec);
605 else // extwarn.
606 Diag(Tok, diag::ext_duplicate_declspec, PrevSpec);
607 }
608 ConsumeToken();
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000609 }
610}
611
Chris Lattnerd5d0a6c2006-08-07 00:58:14 +0000612
613/// ParseDeclarator - Parse and verify a newly-initialized declarator.
614///
615void Parser::ParseDeclarator(Declarator &D) {
616 /// This implements the 'declarator' production in the C grammar, then checks
617 /// for well-formedness and issues diagnostics.
618 ParseDeclaratorInternal(D);
619
Chris Lattner9fab3b92006-08-12 18:25:42 +0000620 // TODO: validate D.
Chris Lattnerbf320c82006-08-07 05:05:30 +0000621
Chris Lattnerd5d0a6c2006-08-07 00:58:14 +0000622}
623
624/// ParseDeclaratorInternal
Chris Lattner6c7416c2006-08-07 00:19:33 +0000625/// declarator: [C99 6.7.5]
626/// pointer[opt] direct-declarator
627///
628/// pointer: [C99 6.7.5]
629/// '*' type-qualifier-list[opt]
630/// '*' type-qualifier-list[opt] pointer
631///
Chris Lattnerd5d0a6c2006-08-07 00:58:14 +0000632void Parser::ParseDeclaratorInternal(Declarator &D) {
Chris Lattner6c7416c2006-08-07 00:19:33 +0000633 if (Tok.getKind() != tok::star)
634 return ParseDirectDeclarator(D);
635
636 // Otherwise, '*' -> pointer.
637 SourceLocation Loc = Tok.getLocation();
638 ConsumeToken(); // Eat the *.
639 DeclSpec DS;
640 ParseTypeQualifierListOpt(DS);
641
642 // Recursively parse the declarator.
Chris Lattnerd5d0a6c2006-08-07 00:58:14 +0000643 ParseDeclaratorInternal(D);
Chris Lattner6c7416c2006-08-07 00:19:33 +0000644
645 // Remember that we parsed a pointer type, and remember the type-quals.
646 D.AddTypeInfo(DeclaratorTypeInfo::getPointer(DS.TypeQualifiers, Loc));
647}
648
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000649
650/// ParseDirectDeclarator
651/// direct-declarator: [C99 6.7.5]
652/// identifier
653/// '(' declarator ')'
654/// [GNU] '(' attributes declarator ')'
Chris Lattnere8074e62006-08-06 18:30:15 +0000655/// [C90] direct-declarator '[' constant-expression[opt] ']'
656/// [C99] direct-declarator '[' type-qual-list[opt] assignment-expr[opt] ']'
657/// [C99] direct-declarator '[' 'static' type-qual-list[opt] assign-expr ']'
658/// [C99] direct-declarator '[' type-qual-list 'static' assignment-expr ']'
659/// [C99] direct-declarator '[' type-qual-list[opt] '*' ']'
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000660/// direct-declarator '(' parameter-type-list ')'
661/// direct-declarator '(' identifier-list[opt] ')'
662/// [GNU] direct-declarator '(' parameter-forward-declarations
663/// parameter-type-list[opt] ')'
664///
Chris Lattneracd58a32006-08-06 17:24:14 +0000665void Parser::ParseDirectDeclarator(Declarator &D) {
666 // Parse the first direct-declarator seen.
667 if (Tok.getKind() == tok::identifier && D.mayHaveIdentifier()) {
668 assert(Tok.getIdentifierInfo() && "Not an identifier?");
669 D.SetIdentifier(Tok.getIdentifierInfo(), Tok.getLocation());
670 ConsumeToken();
671 } else if (Tok.getKind() == tok::l_paren) {
672 // direct-declarator: '(' declarator ')'
673 // direct-declarator: '(' attributes declarator ')' [TODO]
674 // Example: 'char (*X)' or 'int (*XX)(void)'
675 ParseParenDeclarator(D);
Chris Lattneracd58a32006-08-06 17:24:14 +0000676 } else if (D.mayOmitIdentifier()) {
677 // This could be something simple like "int" (in which case the declarator
678 // portion is empty), if an abstract-declarator is allowed.
679 D.SetIdentifier(0, Tok.getLocation());
680 } else {
Chris Lattnereec40f92006-08-06 21:55:29 +0000681 // Expected identifier or '('.
682 Diag(Tok, diag::err_expected_ident_lparen);
683 D.SetIdentifier(0, Tok.getLocation());
Chris Lattneracd58a32006-08-06 17:24:14 +0000684 }
685
686 assert(D.isPastIdentifier() &&
687 "Haven't past the location of the identifier yet?");
688
689 while (1) {
690 if (Tok.getKind() == tok::l_paren) {
691 ParseParenDeclarator(D);
692 } else if (Tok.getKind() == tok::l_square) {
Chris Lattnere8074e62006-08-06 18:30:15 +0000693 ParseBracketDeclarator(D);
Chris Lattneracd58a32006-08-06 17:24:14 +0000694 } else {
695 break;
696 }
697 }
698}
699
700/// ParseParenDeclarator - We parsed the declarator D up to a paren. This may
701/// either be before the identifier (in which case these are just grouping
702/// parens for precedence) or it may be after the identifier, in which case
703/// these are function arguments.
704///
705/// This method also handles this portion of the grammar:
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000706/// parameter-type-list: [C99 6.7.5]
707/// parameter-list
708/// parameter-list ',' '...'
709///
710/// parameter-list: [C99 6.7.5]
711/// parameter-declaration
712/// parameter-list ',' parameter-declaration
713///
714/// parameter-declaration: [C99 6.7.5]
715/// declaration-specifiers declarator
Chris Lattneracd58a32006-08-06 17:24:14 +0000716/// [GNU] declaration-specifiers declarator attributes [TODO]
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000717/// declaration-specifiers abstract-declarator[opt]
Chris Lattneracd58a32006-08-06 17:24:14 +0000718/// [GNU] declaration-specifiers abstract-declarator[opt] attributes [TODO]
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000719///
720/// identifier-list: [C99 6.7.5]
721/// identifier
722/// identifier-list ',' identifier
723///
Chris Lattneracd58a32006-08-06 17:24:14 +0000724void Parser::ParseParenDeclarator(Declarator &D) {
Chris Lattnerd5d0a6c2006-08-07 00:58:14 +0000725 SourceLocation StartLoc = Tok.getLocation();
Chris Lattneracd58a32006-08-06 17:24:14 +0000726 ConsumeParen();
Chris Lattnerd9c3c592006-08-05 06:26:47 +0000727
Chris Lattneracd58a32006-08-06 17:24:14 +0000728 // If we haven't past the identifier yet (or where the identifier would be
729 // stored, if this is an abstract declarator), then this is probably just
730 // grouping parens.
731 if (!D.isPastIdentifier()) {
732 // Okay, this is probably a grouping paren. However, if this could be an
733 // abstract-declarator, then this could also be the start of function
734 // arguments (consider 'void()').
735 bool isGrouping;
736
737 if (!D.mayOmitIdentifier()) {
738 // If this can't be an abstract-declarator, this *must* be a grouping
739 // paren, because we haven't seen the identifier yet.
740 isGrouping = true;
741 } else if (Tok.getKind() == tok::r_paren || // 'int()' is a function.
742 isDeclarationSpecifier()) { // 'int(int)' is a function.
743
744 isGrouping = false;
Chris Lattnerd9c3c592006-08-05 06:26:47 +0000745 } else {
Chris Lattnera3507222006-08-07 00:33:37 +0000746 // Otherwise, this is a grouping paren, e.g. 'int (*X)'.
Chris Lattneracd58a32006-08-06 17:24:14 +0000747 isGrouping = true;
Chris Lattnerd9c3c592006-08-05 06:26:47 +0000748 }
Chris Lattneracd58a32006-08-06 17:24:14 +0000749
750 // If this is a grouping paren, handle:
751 // direct-declarator: '(' declarator ')'
752 // direct-declarator: '(' attributes declarator ')' [TODO]
753 if (isGrouping) {
Chris Lattnerd5d0a6c2006-08-07 00:58:14 +0000754 ParseDeclaratorInternal(D);
Chris Lattner4564bc12006-08-10 23:14:52 +0000755 // Match the ')'.
756 MatchRHSPunctuation(tok::r_paren, StartLoc, "(",
757 diag::err_expected_rparen);
Chris Lattneracd58a32006-08-06 17:24:14 +0000758 return;
759 }
760
761 // Okay, if this wasn't a grouping paren, it must be the start of a function
Chris Lattnera3507222006-08-07 00:33:37 +0000762 // argument list. Recognize that this declarator will never have an
763 // identifier (and remember where it would have been), then fall through to
764 // the handling of argument lists.
Chris Lattneracd58a32006-08-06 17:24:14 +0000765 D.SetIdentifier(0, Tok.getLocation());
Chris Lattnerd9c3c592006-08-05 06:26:47 +0000766 }
767
Chris Lattneracd58a32006-08-06 17:24:14 +0000768 // Okay, this is the parameter list of a function definition, or it is an
769 // identifier list of a K&R-style function.
770
Chris Lattner9fab3b92006-08-12 18:25:42 +0000771 // TODO: enter function-declaration scope, limiting any declarators for
Chris Lattneracd58a32006-08-06 17:24:14 +0000772 // arguments to the function scope.
773 // NOTE: better to only create a scope if not '()'
Chris Lattnerd5d0a6c2006-08-07 00:58:14 +0000774 bool IsVariadic;
Chris Lattneracd58a32006-08-06 17:24:14 +0000775 bool HasPrototype;
Chris Lattnerfff824f2006-08-07 06:31:38 +0000776 bool IsEmpty = false;
Chris Lattner14776b92006-08-06 22:27:40 +0000777 bool ErrorEmitted = false;
778
Chris Lattneracd58a32006-08-06 17:24:14 +0000779 if (Tok.getKind() == tok::r_paren) {
780 // int() -> no prototype, no '...'.
Chris Lattnerd5d0a6c2006-08-07 00:58:14 +0000781 IsVariadic = false;
Chris Lattneracd58a32006-08-06 17:24:14 +0000782 HasPrototype = false;
Chris Lattnerfff824f2006-08-07 06:31:38 +0000783 IsEmpty = true;
Chris Lattneracd58a32006-08-06 17:24:14 +0000784 } else if (Tok.getKind() == tok::identifier &&
Chris Lattner0ccd51e2006-08-09 05:47:47 +0000785 1/*TODO: !isatypedefname(Tok.getIdentifierInfo())*/) {
Chris Lattneracd58a32006-08-06 17:24:14 +0000786 // Identifier list. Note that '(' identifier-list ')' is only allowed for
787 // normal declarators, not for abstract-declarators.
788 assert(D.isPastIdentifier() && "Identifier (if present) must be passed!");
789
790 // If there was no identifier specified, either we are in an
791 // abstract-declarator, or we are in a parameter declarator which was found
792 // to be abstract. In abstract-declarators, identifier lists are not valid,
793 // diagnose this.
794 if (!D.getIdentifier())
795 Diag(Tok, diag::ext_ident_list_in_param);
796
Chris Lattner9fab3b92006-08-12 18:25:42 +0000797 // TODO: Remember token.
Chris Lattneracd58a32006-08-06 17:24:14 +0000798 ConsumeToken();
799 while (Tok.getKind() == tok::comma) {
800 // Eat the comma.
801 ConsumeToken();
802
Chris Lattner0be454e2006-08-12 19:30:51 +0000803 if (ExpectAndConsume(tok::identifier, diag::err_expected_ident)) {
Chris Lattner14776b92006-08-06 22:27:40 +0000804 ErrorEmitted = true;
805 break;
806 }
Chris Lattneracd58a32006-08-06 17:24:14 +0000807 }
808
Chris Lattneracd58a32006-08-06 17:24:14 +0000809 // K&R 'prototype'.
Chris Lattnerd5d0a6c2006-08-07 00:58:14 +0000810 IsVariadic = false;
Chris Lattneracd58a32006-08-06 17:24:14 +0000811 HasPrototype = false;
812 } else {
Chris Lattnerd5d0a6c2006-08-07 00:58:14 +0000813 IsVariadic = false;
Chris Lattneracd58a32006-08-06 17:24:14 +0000814 bool ReadArg = false;
815 // Finally, a normal, non-empty parameter type list.
816 while (1) {
817 if (Tok.getKind() == tok::ellipsis) {
Chris Lattnerd5d0a6c2006-08-07 00:58:14 +0000818 IsVariadic = true;
Chris Lattneracd58a32006-08-06 17:24:14 +0000819
820 // Check to see if this is "void(...)" which is not allowed.
821 if (!ReadArg) {
Chris Lattnere8074e62006-08-06 18:30:15 +0000822 // Otherwise, parse parameter type list. If it starts with an
823 // ellipsis, diagnose the malformed function.
Chris Lattneracd58a32006-08-06 17:24:14 +0000824 Diag(Tok, diag::err_ellipsis_first_arg);
Chris Lattnerd5d0a6c2006-08-07 00:58:14 +0000825 IsVariadic = false; // Treat this like 'void()'.
Chris Lattneracd58a32006-08-06 17:24:14 +0000826 }
827
828 // Consume the ellipsis.
829 ConsumeToken();
830 break;
831 }
832
833 ReadArg = true;
834
835 // Parse the declaration-specifiers.
836 DeclSpec DS;
837 ParseDeclarationSpecifiers(DS);
838
839 // Parse the declarator. This is "PrototypeContext", because we must
840 // accept either 'declarator' or 'abstract-declarator' here.
841 Declarator DeclaratorInfo(DS, Declarator::PrototypeContext);
842 ParseDeclarator(DeclaratorInfo);
843
844 // TODO: do something with the declarator, if it is valid.
845
846 // If the next token is a comma, consume it and keep reading arguments.
847 if (Tok.getKind() != tok::comma) break;
848
849 // Consume the comma.
850 ConsumeToken();
851 }
852
853 HasPrototype = true;
854 }
855
Chris Lattner9fab3b92006-08-12 18:25:42 +0000856 // TODO: pop the scope.
Chris Lattnerd5d0a6c2006-08-07 00:58:14 +0000857
Chris Lattner9fab3b92006-08-12 18:25:42 +0000858 // TODO: capture argument info.
Chris Lattneracd58a32006-08-06 17:24:14 +0000859
Chris Lattnerd5d0a6c2006-08-07 00:58:14 +0000860 // Remember that we parsed a function type, and remember the attributes.
861 D.AddTypeInfo(DeclaratorTypeInfo::getFunction(HasPrototype, IsVariadic,
Chris Lattnerfff824f2006-08-07 06:31:38 +0000862 IsEmpty, StartLoc));
Chris Lattnerd5d0a6c2006-08-07 00:58:14 +0000863
Chris Lattner14776b92006-08-06 22:27:40 +0000864
865 // If we have the closing ')', eat it and we're done.
866 if (Tok.getKind() == tok::r_paren) {
867 ConsumeParen();
868 } else {
869 // If an error happened earlier parsing something else in the proto, don't
870 // issue another error.
871 if (!ErrorEmitted)
872 Diag(Tok, diag::err_expected_rparen);
873 SkipUntil(tok::r_paren);
874 }
Chris Lattnerc0acd3d2006-07-31 05:13:43 +0000875}
Chris Lattneracd58a32006-08-06 17:24:14 +0000876
Chris Lattnere8074e62006-08-06 18:30:15 +0000877
878/// [C90] direct-declarator '[' constant-expression[opt] ']'
879/// [C99] direct-declarator '[' type-qual-list[opt] assignment-expr[opt] ']'
880/// [C99] direct-declarator '[' 'static' type-qual-list[opt] assign-expr ']'
881/// [C99] direct-declarator '[' type-qual-list 'static' assignment-expr ']'
882/// [C99] direct-declarator '[' type-qual-list[opt] '*' ']'
883void Parser::ParseBracketDeclarator(Declarator &D) {
884 SourceLocation StartLoc = Tok.getLocation();
Chris Lattnereec40f92006-08-06 21:55:29 +0000885 ConsumeBracket();
Chris Lattnere8074e62006-08-06 18:30:15 +0000886
887 // If valid, this location is the position where we read the 'static' keyword.
888 SourceLocation StaticLoc;
889 if (Tok.getKind() == tok::kw_static) {
890 StaticLoc = Tok.getLocation();
891 ConsumeToken();
892 }
893
894 // If there is a type-qualifier-list, read it now.
895 DeclSpec DS;
896 ParseTypeQualifierListOpt(DS);
Chris Lattnere8074e62006-08-06 18:30:15 +0000897
898 // If we haven't already read 'static', check to see if there is one after the
899 // type-qualifier-list.
900 if (!StaticLoc.isValid() && Tok.getKind() == tok::kw_static) {
901 StaticLoc = Tok.getLocation();
902 ConsumeToken();
903 }
904
905 // Handle "direct-declarator [ type-qual-list[opt] * ]".
Chris Lattnere8074e62006-08-06 18:30:15 +0000906 bool isStar = false;
Chris Lattner62591722006-08-12 18:40:58 +0000907 ExprResult NumElements(false);
Chris Lattner1906f802006-08-06 19:14:46 +0000908 if (Tok.getKind() == tok::star) {
909 // Remember the '*' token, in case we have to un-get it.
910 LexerToken StarTok = Tok;
Chris Lattnere8074e62006-08-06 18:30:15 +0000911 ConsumeToken();
Chris Lattner1906f802006-08-06 19:14:46 +0000912
913 // Check that the ']' token is present to avoid incorrectly parsing
914 // expressions starting with '*' as [*].
915 if (Tok.getKind() == tok::r_square) {
916 if (StaticLoc.isValid())
917 Diag(StaticLoc, diag::err_unspecified_vla_size_with_static);
918 StaticLoc = SourceLocation(); // Drop the static.
919 isStar = true;
Chris Lattner1906f802006-08-06 19:14:46 +0000920 } else {
921 // Otherwise, the * must have been some expression (such as '*ptr') that
Chris Lattner9fab3b92006-08-12 18:25:42 +0000922 // started an assignment-expr. We already consumed the token, but now we
Chris Lattner62591722006-08-12 18:40:58 +0000923 // need to reparse it. This handles cases like 'X[*p + 4]'
924 NumElements = ParseAssignmentExpressionWithLeadingStar(StarTok);
Chris Lattner1906f802006-08-06 19:14:46 +0000925 }
Chris Lattner9fab3b92006-08-12 18:25:42 +0000926 } else if (Tok.getKind() != tok::r_square) {
Chris Lattnere8074e62006-08-06 18:30:15 +0000927 // Parse the assignment-expression now.
Chris Lattner62591722006-08-12 18:40:58 +0000928 NumElements = ParseAssignmentExpression();
929 }
930
931 // If there was an error parsing the assignment-expression, recover.
932 if (NumElements.isInvalid) {
933 // If the expression was invalid, skip it.
934 SkipUntil(tok::r_square);
935 return;
Chris Lattnere8074e62006-08-06 18:30:15 +0000936 }
937
Chris Lattner9fab3b92006-08-12 18:25:42 +0000938 MatchRHSPunctuation(tok::r_square, StartLoc, "[", diag::err_expected_rsquare);
939
Chris Lattnere8074e62006-08-06 18:30:15 +0000940 // If C99 isn't enabled, emit an ext-warn if the arg list wasn't empty and if
941 // it was not a constant expression.
942 if (!getLang().C99) {
943 // TODO: check C90 array constant exprness.
Chris Lattner0e894622006-08-13 19:58:17 +0000944 if (isStar || StaticLoc.isValid() ||
945 0/*TODO: NumElts is not a C90 constantexpr */)
Chris Lattner8a39edc2006-08-06 18:33:32 +0000946 Diag(StartLoc, diag::ext_c99_array_usage);
Chris Lattnere8074e62006-08-06 18:30:15 +0000947 }
Chris Lattner6c7416c2006-08-07 00:19:33 +0000948
949 // Remember that we parsed a pointer type, and remember the type-quals.
950 D.AddTypeInfo(DeclaratorTypeInfo::getArray(DS.TypeQualifiers,
951 StaticLoc.isValid(), isStar,
Chris Lattner62591722006-08-12 18:40:58 +0000952 NumElements.Val, StartLoc));
Chris Lattnere8074e62006-08-06 18:30:15 +0000953}
954