blob: 32b00117683c5cca3b59c7df29b2bc6e70160984 [file] [log] [blame]
Chris Lattner289ab7b2006-11-08 06:54:53 +00001//===--- SemaDeclSpec.cpp - Declaration Specifier Semantic Analysis -------===//
Chris Lattnerb9093cd2006-08-04 04:39:53 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner5b12ab82007-12-29 19:59:25 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Chris Lattnerb9093cd2006-08-04 04:39:53 +00007//
8//===----------------------------------------------------------------------===//
9//
Chris Lattner289ab7b2006-11-08 06:54:53 +000010// This file implements semantic analysis for declaration specifiers.
Chris Lattnerb9093cd2006-08-04 04:39:53 +000011//
12//===----------------------------------------------------------------------===//
13
Chris Lattner288e86ff12006-11-11 23:03:42 +000014#include "clang/Parse/DeclSpec.h"
Chris Lattner60f36222009-01-29 05:15:15 +000015#include "clang/Parse/ParseDiagnostic.h"
Chris Lattnerda48a8e2006-08-04 05:25:55 +000016#include "clang/Basic/LangOptions.h"
Chris Lattner1ce41ed2009-01-20 19:11:22 +000017#include "llvm/ADT/STLExtras.h"
Chris Lattnerb9093cd2006-08-04 04:39:53 +000018using namespace clang;
19
Chris Lattner3b0f3ef2008-11-22 08:32:36 +000020
21static DiagnosticBuilder Diag(Diagnostic &D, SourceLocation Loc,
22 SourceManager &SrcMgr, unsigned DiagID) {
23 return D.Report(FullSourceLoc(Loc, SrcMgr), DiagID);
24}
25
26
Chris Lattner1ce41ed2009-01-20 19:11:22 +000027/// DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
28/// "TheDeclarator" is the declarator that this will be added to.
29DeclaratorChunk DeclaratorChunk::getFunction(bool hasProto, bool isVariadic,
30 ParamInfo *ArgInfo,
31 unsigned NumArgs,
32 unsigned TypeQuals,
33 SourceLocation Loc,
34 Declarator &TheDeclarator) {
35 DeclaratorChunk I;
36 I.Kind = Function;
37 I.Loc = Loc;
38 I.Fun.hasPrototype = hasProto;
39 I.Fun.isVariadic = isVariadic;
40 I.Fun.DeleteArgInfo = false;
41 I.Fun.TypeQuals = TypeQuals;
42 I.Fun.NumArgs = NumArgs;
43 I.Fun.ArgInfo = 0;
44
45 // new[] an argument array if needed.
46 if (NumArgs) {
47 // If the 'InlineParams' in Declarator is unused and big enough, put our
48 // parameter list there (in an effort to avoid new/delete traffic). If it
49 // is already used (consider a function returning a function pointer) or too
50 // small (function taking too many arguments), go to the heap.
51 if (!TheDeclarator.InlineParamsUsed &&
52 NumArgs <= llvm::array_lengthof(TheDeclarator.InlineParams)) {
53 I.Fun.ArgInfo = TheDeclarator.InlineParams;
54 I.Fun.DeleteArgInfo = false;
55 TheDeclarator.InlineParamsUsed = true;
56 } else {
57 I.Fun.ArgInfo = new DeclaratorChunk::ParamInfo[NumArgs];
58 I.Fun.DeleteArgInfo = true;
59 }
60 memcpy(I.Fun.ArgInfo, ArgInfo, sizeof(ArgInfo[0])*NumArgs);
61 }
62 return I;
63}
Chris Lattner3b0f3ef2008-11-22 08:32:36 +000064
Chris Lattnerb9093cd2006-08-04 04:39:53 +000065/// getParsedSpecifiers - Return a bitmask of which flavors of specifiers this
66///
67unsigned DeclSpec::getParsedSpecifiers() const {
68 unsigned Res = 0;
Chris Lattnerf63f89a2006-08-05 03:28:50 +000069 if (StorageClassSpec != SCS_unspecified ||
70 SCS_thread_specified)
Chris Lattnerb9093cd2006-08-04 04:39:53 +000071 Res |= PQ_StorageClassSpecifier;
Mike Stump65643c62008-06-19 19:52:46 +000072
Chris Lattner4d8f8732006-11-28 05:05:08 +000073 if (TypeQualifiers != TQ_unspecified)
Chris Lattnerb9093cd2006-08-04 04:39:53 +000074 Res |= PQ_TypeQualifier;
75
Chris Lattnerf055d432006-11-28 04:28:12 +000076 if (hasTypeSpecifier())
Chris Lattnerb9093cd2006-08-04 04:39:53 +000077 Res |= PQ_TypeSpecifier;
78
Douglas Gregor61956c42008-10-31 09:07:45 +000079 if (FS_inline_specified || FS_virtual_specified || FS_explicit_specified)
Chris Lattnerb9093cd2006-08-04 04:39:53 +000080 Res |= PQ_FunctionSpecifier;
81 return Res;
82}
83
Chris Lattner7bd11fe2007-01-23 04:35:33 +000084const char *DeclSpec::getSpecifierName(DeclSpec::SCS S) {
Chris Lattnerf63f89a2006-08-05 03:28:50 +000085 switch (S) {
86 default: assert(0 && "Unknown typespec!");
87 case DeclSpec::SCS_unspecified: return "unspecified";
88 case DeclSpec::SCS_typedef: return "typedef";
89 case DeclSpec::SCS_extern: return "extern";
90 case DeclSpec::SCS_static: return "static";
91 case DeclSpec::SCS_auto: return "auto";
92 case DeclSpec::SCS_register: return "register";
Sebastian Redlccdfaba2008-11-14 23:42:31 +000093 case DeclSpec::SCS_mutable: return "mutable";
Chris Lattnerf63f89a2006-08-05 03:28:50 +000094 }
95}
96
Steve Naroffab468cb2008-02-12 04:08:59 +000097bool DeclSpec::BadSpecifier(SCS S, const char *&PrevSpec) {
Steve Naroffab468cb2008-02-12 04:08:59 +000098 PrevSpec = getSpecifierName(S);
Chris Lattnerf63f89a2006-08-05 03:28:50 +000099 return true;
100}
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000101
Steve Naroffab468cb2008-02-12 04:08:59 +0000102bool DeclSpec::BadSpecifier(TSW W, const char *&PrevSpec) {
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000103 switch (W) {
Steve Naroffab468cb2008-02-12 04:08:59 +0000104 case TSW_unspecified: PrevSpec = "unspecified"; break;
105 case TSW_short: PrevSpec = "short"; break;
106 case TSW_long: PrevSpec = "long"; break;
107 case TSW_longlong: PrevSpec = "long long"; break;
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000108 }
109 return true;
110}
111
Steve Naroffab468cb2008-02-12 04:08:59 +0000112bool DeclSpec::BadSpecifier(TSC C, const char *&PrevSpec) {
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000113 switch (C) {
Steve Naroffab468cb2008-02-12 04:08:59 +0000114 case TSC_unspecified: PrevSpec = "unspecified"; break;
115 case TSC_imaginary: PrevSpec = "imaginary"; break;
116 case TSC_complex: PrevSpec = "complex"; break;
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000117 }
118 return true;
119}
120
121
Steve Naroffab468cb2008-02-12 04:08:59 +0000122bool DeclSpec::BadSpecifier(TSS S, const char *&PrevSpec) {
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000123 switch (S) {
Steve Naroffab468cb2008-02-12 04:08:59 +0000124 case TSS_unspecified: PrevSpec = "unspecified"; break;
125 case TSS_signed: PrevSpec = "signed"; break;
126 case TSS_unsigned: PrevSpec = "unsigned"; break;
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000127 }
128 return true;
129}
130
Chris Lattner69680ea2007-01-23 04:34:43 +0000131const char *DeclSpec::getSpecifierName(DeclSpec::TST T) {
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000132 switch (T) {
Chris Lattner839713c2006-08-04 06:15:52 +0000133 default: assert(0 && "Unknown typespec!");
134 case DeclSpec::TST_unspecified: return "unspecified";
135 case DeclSpec::TST_void: return "void";
136 case DeclSpec::TST_char: return "char";
Argyrios Kyrtzidis40e9e482008-08-09 16:51:54 +0000137 case DeclSpec::TST_wchar: return "wchar_t";
Chris Lattner839713c2006-08-04 06:15:52 +0000138 case DeclSpec::TST_int: return "int";
139 case DeclSpec::TST_float: return "float";
140 case DeclSpec::TST_double: return "double";
141 case DeclSpec::TST_bool: return "_Bool";
142 case DeclSpec::TST_decimal32: return "_Decimal32";
143 case DeclSpec::TST_decimal64: return "_Decimal64";
144 case DeclSpec::TST_decimal128: return "_Decimal128";
Chris Lattnerda72c822006-08-13 22:16:42 +0000145 case DeclSpec::TST_enum: return "enum";
Chris Lattner861a2262008-04-13 18:59:07 +0000146 case DeclSpec::TST_class: return "class";
Chris Lattnerda72c822006-08-13 22:16:42 +0000147 case DeclSpec::TST_union: return "union";
148 case DeclSpec::TST_struct: return "struct";
Chris Lattner3b4fdda32006-08-14 00:45:39 +0000149 case DeclSpec::TST_typedef: return "typedef";
Steve Naroffad373bd2007-07-31 12:34:36 +0000150 case DeclSpec::TST_typeofType:
151 case DeclSpec::TST_typeofExpr: return "typeof";
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000152 }
Chris Lattner839713c2006-08-04 06:15:52 +0000153}
154
Steve Naroffab468cb2008-02-12 04:08:59 +0000155bool DeclSpec::BadSpecifier(TST T, const char *&PrevSpec) {
Steve Naroffab468cb2008-02-12 04:08:59 +0000156 PrevSpec = getSpecifierName(T);
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000157 return true;
158}
159
Steve Naroffab468cb2008-02-12 04:08:59 +0000160bool DeclSpec::BadSpecifier(TQ T, const char *&PrevSpec) {
Chris Lattnerda48a8e2006-08-04 05:25:55 +0000161 switch (T) {
162 case DeclSpec::TQ_unspecified: PrevSpec = "unspecified"; break;
163 case DeclSpec::TQ_const: PrevSpec = "const"; break;
164 case DeclSpec::TQ_restrict: PrevSpec = "restrict"; break;
165 case DeclSpec::TQ_volatile: PrevSpec = "volatile"; break;
166 }
167 return true;
168}
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000169
Chris Lattner4d8f8732006-11-28 05:05:08 +0000170bool DeclSpec::SetStorageClassSpec(SCS S, SourceLocation Loc,
171 const char *&PrevSpec) {
Chris Lattnerf63f89a2006-08-05 03:28:50 +0000172 if (StorageClassSpec != SCS_unspecified)
Chris Lattner3b0f3ef2008-11-22 08:32:36 +0000173 return BadSpecifier((SCS)StorageClassSpec, PrevSpec);
Chris Lattnerf63f89a2006-08-05 03:28:50 +0000174 StorageClassSpec = S;
Chris Lattner4d8f8732006-11-28 05:05:08 +0000175 StorageClassSpecLoc = Loc;
Sebastian Redlccdfaba2008-11-14 23:42:31 +0000176 assert((unsigned)S == StorageClassSpec && "SCS constants overflow bitfield");
Chris Lattnerf63f89a2006-08-05 03:28:50 +0000177 return false;
178}
179
Chris Lattner4d8f8732006-11-28 05:05:08 +0000180bool DeclSpec::SetStorageClassSpecThread(SourceLocation Loc,
181 const char *&PrevSpec) {
Chris Lattner353f5742006-11-28 04:50:12 +0000182 if (SCS_thread_specified) {
183 PrevSpec = "__thread";
184 return true;
185 }
186 SCS_thread_specified = true;
Chris Lattner4d8f8732006-11-28 05:05:08 +0000187 SCS_threadLoc = Loc;
Chris Lattner353f5742006-11-28 04:50:12 +0000188 return false;
189}
190
Chris Lattnerf63f89a2006-08-05 03:28:50 +0000191
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000192/// These methods set the specified attribute of the DeclSpec, but return true
193/// and ignore the request if invalid (e.g. "extern" then "auto" is
194/// specified).
Chris Lattnerb20e8942006-11-28 05:30:29 +0000195bool DeclSpec::SetTypeSpecWidth(TSW W, SourceLocation Loc,
196 const char *&PrevSpec) {
Chris Lattner353f5742006-11-28 04:50:12 +0000197 if (TypeSpecWidth != TSW_unspecified &&
198 // Allow turning long -> long long.
199 (W != TSW_longlong || TypeSpecWidth != TSW_long))
Chris Lattner3b0f3ef2008-11-22 08:32:36 +0000200 return BadSpecifier((TSW)TypeSpecWidth, PrevSpec);
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000201 TypeSpecWidth = W;
Chris Lattnerb20e8942006-11-28 05:30:29 +0000202 TSWLoc = Loc;
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000203 return false;
204}
205
Chris Lattnerb20e8942006-11-28 05:30:29 +0000206bool DeclSpec::SetTypeSpecComplex(TSC C, SourceLocation Loc,
207 const char *&PrevSpec) {
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000208 if (TypeSpecComplex != TSC_unspecified)
Chris Lattner3b0f3ef2008-11-22 08:32:36 +0000209 return BadSpecifier((TSC)TypeSpecComplex, PrevSpec);
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000210 TypeSpecComplex = C;
Chris Lattnerb20e8942006-11-28 05:30:29 +0000211 TSCLoc = Loc;
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000212 return false;
213}
214
Chris Lattnerb20e8942006-11-28 05:30:29 +0000215bool DeclSpec::SetTypeSpecSign(TSS S, SourceLocation Loc,
216 const char *&PrevSpec) {
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000217 if (TypeSpecSign != TSS_unspecified)
Chris Lattner3b0f3ef2008-11-22 08:32:36 +0000218 return BadSpecifier((TSS)TypeSpecSign, PrevSpec);
Chris Lattnerdeb42f52006-08-04 05:26:52 +0000219 TypeSpecSign = S;
Chris Lattnerb20e8942006-11-28 05:30:29 +0000220 TSSLoc = Loc;
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000221 return false;
222}
223
Chris Lattnerb20e8942006-11-28 05:30:29 +0000224bool DeclSpec::SetTypeSpecType(TST T, SourceLocation Loc,
Argyrios Kyrtzidis25d05e82008-08-01 10:35:27 +0000225 const char *&PrevSpec, Action::TypeTy *Rep) {
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000226 if (TypeSpecType != TST_unspecified)
Chris Lattner3b0f3ef2008-11-22 08:32:36 +0000227 return BadSpecifier((TST)TypeSpecType, PrevSpec);
Chris Lattnerdeb42f52006-08-04 05:26:52 +0000228 TypeSpecType = T;
Chris Lattnerb9d572a2007-01-23 04:58:34 +0000229 TypeRep = Rep;
Chris Lattnerb20e8942006-11-28 05:30:29 +0000230 TSTLoc = Loc;
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000231 return false;
232}
233
Chris Lattner60809f52006-11-28 05:18:46 +0000234bool DeclSpec::SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec,
Chris Lattnerda48a8e2006-08-04 05:25:55 +0000235 const LangOptions &Lang) {
236 // Duplicates turn into warnings pre-C99.
237 if ((TypeQualifiers & T) && !Lang.C99)
238 return BadSpecifier(T, PrevSpec);
239 TypeQualifiers |= T;
Chris Lattner60809f52006-11-28 05:18:46 +0000240
241 switch (T) {
242 default: assert(0 && "Unknown type qualifier!");
243 case TQ_const: TQ_constLoc = Loc; break;
244 case TQ_restrict: TQ_restrictLoc = Loc; break;
245 case TQ_volatile: TQ_volatileLoc = Loc; break;
246 }
Chris Lattnerda48a8e2006-08-04 05:25:55 +0000247 return false;
248}
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000249
Chris Lattner1b22eed2006-11-28 05:12:07 +0000250bool DeclSpec::SetFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec){
Chris Lattnera925dc62006-11-28 04:33:46 +0000251 // 'inline inline' is ok.
252 FS_inline_specified = true;
Chris Lattner1b22eed2006-11-28 05:12:07 +0000253 FS_inlineLoc = Loc;
Chris Lattnera925dc62006-11-28 04:33:46 +0000254 return false;
255}
256
Douglas Gregor61956c42008-10-31 09:07:45 +0000257bool DeclSpec::SetFunctionSpecVirtual(SourceLocation Loc, const char *&PrevSpec){
258 // 'virtual virtual' is ok.
259 FS_virtual_specified = true;
260 FS_virtualLoc = Loc;
261 return false;
262}
263
264bool DeclSpec::SetFunctionSpecExplicit(SourceLocation Loc, const char *&PrevSpec){
265 // 'explicit explicit' is ok.
266 FS_explicit_specified = true;
267 FS_explicitLoc = Loc;
268 return false;
269}
270
Chris Lattnera925dc62006-11-28 04:33:46 +0000271
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000272/// Finish - This does final analysis of the declspec, rejecting things like
273/// "_Imaginary" (lacking an FP type). This returns a diagnostic to issue or
274/// diag::NUM_DIAGNOSTICS if there is no error. After calling this method,
275/// DeclSpec is guaranteed self-consistent, even if an error occurred.
Ted Kremenekd4e5fba2007-12-11 21:27:55 +0000276void DeclSpec::Finish(Diagnostic &D, SourceManager& SrcMgr,
277 const LangOptions &Lang) {
Chris Lattnerfef9d2b2006-08-04 06:36:52 +0000278 // Check the type specifier components first.
279
Argyrios Kyrtzidis40e9e482008-08-09 16:51:54 +0000280 // signed/unsigned are only valid with int/char/wchar_t.
Chris Lattner839713c2006-08-04 06:15:52 +0000281 if (TypeSpecSign != TSS_unspecified) {
Chris Lattnerfef9d2b2006-08-04 06:36:52 +0000282 if (TypeSpecType == TST_unspecified)
283 TypeSpecType = TST_int; // unsigned -> unsigned int, signed -> signed int.
Argyrios Kyrtzidis40e9e482008-08-09 16:51:54 +0000284 else if (TypeSpecType != TST_int &&
285 TypeSpecType != TST_char && TypeSpecType != TST_wchar) {
Chris Lattner3b0f3ef2008-11-22 08:32:36 +0000286 Diag(D, TSSLoc, SrcMgr, diag::err_invalid_sign_spec)
287 << getSpecifierName((TST)TypeSpecType);
Chris Lattnerfef9d2b2006-08-04 06:36:52 +0000288 // signed double -> double.
Chris Lattner839713c2006-08-04 06:15:52 +0000289 TypeSpecSign = TSS_unspecified;
290 }
291 }
Chris Lattnerfef9d2b2006-08-04 06:36:52 +0000292
Chris Lattner839713c2006-08-04 06:15:52 +0000293 // Validate the width of the type.
294 switch (TypeSpecWidth) {
295 case TSW_unspecified: break;
296 case TSW_short: // short int
297 case TSW_longlong: // long long int
Chris Lattnerfef9d2b2006-08-04 06:36:52 +0000298 if (TypeSpecType == TST_unspecified)
299 TypeSpecType = TST_int; // short -> short int, long long -> long long int.
300 else if (TypeSpecType != TST_int) {
Ted Kremenekd4e5fba2007-12-11 21:27:55 +0000301 Diag(D, TSWLoc, SrcMgr,
Chris Lattner36982e42007-05-16 17:49:37 +0000302 TypeSpecWidth == TSW_short ? diag::err_invalid_short_spec
Chris Lattner3b0f3ef2008-11-22 08:32:36 +0000303 : diag::err_invalid_longlong_spec)
304 << getSpecifierName((TST)TypeSpecType);
Chris Lattner839713c2006-08-04 06:15:52 +0000305 TypeSpecType = TST_int;
306 }
307 break;
308 case TSW_long: // long double, long int
Chris Lattnerfef9d2b2006-08-04 06:36:52 +0000309 if (TypeSpecType == TST_unspecified)
310 TypeSpecType = TST_int; // long -> long int.
311 else if (TypeSpecType != TST_int && TypeSpecType != TST_double) {
Chris Lattner3b0f3ef2008-11-22 08:32:36 +0000312 Diag(D, TSWLoc, SrcMgr, diag::err_invalid_long_spec)
313 << getSpecifierName((TST)TypeSpecType);
Chris Lattner839713c2006-08-04 06:15:52 +0000314 TypeSpecType = TST_int;
315 }
Chris Lattnerfef9d2b2006-08-04 06:36:52 +0000316 break;
Chris Lattner839713c2006-08-04 06:15:52 +0000317 }
318
Chris Lattner0e894622006-08-13 19:58:17 +0000319 // TODO: if the implementation does not implement _Complex or _Imaginary,
Chris Lattnerfef9d2b2006-08-04 06:36:52 +0000320 // disallow their use. Need information about the backend.
321 if (TypeSpecComplex != TSC_unspecified) {
322 if (TypeSpecType == TST_unspecified) {
Ted Kremenekd4e5fba2007-12-11 21:27:55 +0000323 Diag(D, TSCLoc, SrcMgr, diag::ext_plain_complex);
Chris Lattnerfef9d2b2006-08-04 06:36:52 +0000324 TypeSpecType = TST_double; // _Complex -> _Complex double.
325 } else if (TypeSpecType == TST_int || TypeSpecType == TST_char) {
Chris Lattnerf63f89a2006-08-05 03:28:50 +0000326 // Note that this intentionally doesn't include _Complex _Bool.
Ted Kremenekd4e5fba2007-12-11 21:27:55 +0000327 Diag(D, TSTLoc, SrcMgr, diag::ext_integer_complex);
Chris Lattnerfef9d2b2006-08-04 06:36:52 +0000328 } else if (TypeSpecType != TST_float && TypeSpecType != TST_double) {
Chris Lattner3b0f3ef2008-11-22 08:32:36 +0000329 Diag(D, TSCLoc, SrcMgr, diag::err_invalid_complex_spec)
330 << getSpecifierName((TST)TypeSpecType);
Chris Lattnerfef9d2b2006-08-04 06:36:52 +0000331 TypeSpecComplex = TSC_unspecified;
332 }
333 }
Chris Lattner1ae23292006-08-04 06:42:31 +0000334
Chris Lattnerf63f89a2006-08-05 03:28:50 +0000335 // Verify __thread.
336 if (SCS_thread_specified) {
337 if (StorageClassSpec == SCS_unspecified) {
338 StorageClassSpec = SCS_extern; // '__thread int' -> 'extern __thread int'
339 } else if (StorageClassSpec != SCS_extern &&
340 StorageClassSpec != SCS_static) {
Chris Lattner3b0f3ef2008-11-22 08:32:36 +0000341 Diag(D, getStorageClassSpecLoc(), SrcMgr, diag::err_invalid_thread_spec)
342 << getSpecifierName((SCS)StorageClassSpec);
Chris Lattnerf63f89a2006-08-05 03:28:50 +0000343 SCS_thread_specified = false;
344 }
345 }
Chris Lattner8e90ef62006-08-05 03:30:45 +0000346
347 // Okay, now we can infer the real type.
Chris Lattner8e90ef62006-08-05 03:30:45 +0000348
Chris Lattner0e894622006-08-13 19:58:17 +0000349 // TODO: return "auto function" and other bad things based on the real type.
Chris Lattnerf63f89a2006-08-05 03:28:50 +0000350
Chris Lattner1ae23292006-08-04 06:42:31 +0000351 // 'data definition has no type or storage class'?
Chris Lattnerb9093cd2006-08-04 04:39:53 +0000352}
Daniel Dunbarc74b5cc2008-08-11 03:45:03 +0000353
Sebastian Redla2b5e312008-12-28 15:28:59 +0000354bool DeclSpec::isMissingDeclaratorOk() {
355 TST tst = getTypeSpecType();
356 return (tst == TST_union
357 || tst == TST_struct
358 || tst == TST_class
359 || tst == TST_enum
Douglas Gregorc6f58fe2009-01-12 22:49:06 +0000360 ) && getTypeRep() != 0 && StorageClassSpec != DeclSpec::SCS_typedef;
Sebastian Redla2b5e312008-12-28 15:28:59 +0000361}