blob: e163882802dcb954e97a0dedbe8ce2ac52568f52 [file] [log] [blame]
Chris Lattner697e5d62006-11-09 06:32:27 +00001//===--- SemaDecl.cpp - Semantic Analysis for Declarations ----------------===//
2//
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 semantic analysis for declarations.
11//
12//===----------------------------------------------------------------------===//
13
Chris Lattnere168f762006-11-10 05:29:30 +000014#include "Sema.h"
Chris Lattner5c5fbcc2006-12-03 08:41:30 +000015#include "clang/AST/ASTContext.h"
Chris Lattnere168f762006-11-10 05:29:30 +000016#include "clang/AST/Decl.h"
Chris Lattner1300fb92007-01-23 23:42:53 +000017#include "clang/AST/Expr.h"
Chris Lattnerf84a79c2006-11-11 22:59:23 +000018#include "clang/AST/Type.h"
Chris Lattner591a6752006-11-19 23:16:18 +000019#include "clang/Parse/DeclSpec.h"
Chris Lattnere168f762006-11-10 05:29:30 +000020#include "clang/Parse/Scope.h"
21#include "clang/Lex/IdentifierTable.h"
Chris Lattnerac18be92006-11-20 06:49:47 +000022#include "clang/Basic/LangOptions.h"
Chris Lattner697e5d62006-11-09 06:32:27 +000023using namespace llvm;
24using namespace clang;
25
Chris Lattnere168f762006-11-10 05:29:30 +000026
Chris Lattner2ebe4bb2006-11-20 01:29:42 +000027Sema::DeclTy *Sema::isTypeName(const IdentifierInfo &II, Scope *S) const {
28 return dyn_cast_or_null<TypeDecl>(II.getFETokenInfo<Decl>());
Chris Lattnere168f762006-11-10 05:29:30 +000029}
30
Chris Lattner302b4be2006-11-19 02:31:38 +000031void Sema::PopScope(SourceLocation Loc, Scope *S) {
32 for (Scope::decl_iterator I = S->decl_begin(), E = S->decl_end();
33 I != E; ++I) {
Chris Lattner99d31772007-01-21 22:37:37 +000034 Decl *D = static_cast<Decl*>(*I);
Chris Lattner302b4be2006-11-19 02:31:38 +000035 assert(D && "This decl didn't get pushed??");
Chris Lattnerff65b6b2007-01-23 01:33:16 +000036 IdentifierInfo *II = D->getIdentifier();
37 if (!II) continue;
Chris Lattner302b4be2006-11-19 02:31:38 +000038
Chris Lattnerff65b6b2007-01-23 01:33:16 +000039 // Unlink this decl from the identifier. Because the scope contains decls
40 // in an unordered collection, and because we have multiple identifier
41 // namespaces (e.g. tag, normal, label),the decl may not be the first entry.
42 if (II->getFETokenInfo<Decl>() == D) {
43 // Normal case, no multiple decls in different namespaces.
44 II->setFETokenInfo(D->getNext());
45 } else {
46 // Scan ahead. There are only three namespaces in C, so this loop can
47 // never execute more than 3 times.
48 Decl *SomeDecl = II->getFETokenInfo<Decl>();
49 while (SomeDecl->getNext() != D) {
50 SomeDecl = SomeDecl->getNext();
51 assert(SomeDecl && "Didn't find this decl on its identifier's chain!");
52 }
53 SomeDecl->setNext(D->getNext());
54 }
Chris Lattner302b4be2006-11-19 02:31:38 +000055
Chris Lattner740b2f32006-11-21 01:32:20 +000056 // This will have to be revisited for C++: there we want to nest stuff in
57 // namespace decls etc. Even for C, we might want a top-level translation
58 // unit decl or something.
59 if (!CurFunctionDecl)
60 continue;
61
62 // Chain this decl to the containing function, it now owns the memory for
63 // the decl.
64 D->setNext(CurFunctionDecl->getDeclChain());
65 CurFunctionDecl->setDeclChain(D);
Chris Lattner302b4be2006-11-19 02:31:38 +000066 }
67}
68
Chris Lattner200bdc32006-11-19 02:43:37 +000069/// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
70/// no declarator (e.g. "struct foo;") is parsed.
71Sema::DeclTy *Sema::ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) {
72 // TODO: emit error on 'int;' or 'const enum foo;'.
73 // TODO: emit error on 'typedef int;'
74 // if (!DS.isMissingDeclaratorOk()) Diag(...);
75
76 // TODO: Register 'struct foo;' with the type system as an opaque struct.
77
78 // TODO: Check that we don't already have 'union foo;' or something else
79 // that conflicts.
80 return 0;
81}
82
Chris Lattner18b19622007-01-22 07:39:13 +000083/// LookupScopedDecl - Look up the inner-most declaration in the specified
84/// namespace.
85static Decl *LookupScopedDecl(IdentifierInfo *II, Decl::IdentifierNamespace NS){
86 if (II == 0) return 0;
87
88 // Scan up the scope chain looking for a decl that matches this identifier
89 // that is in the appropriate namespace. This search should not take long, as
90 // shadowing of names is uncommon, and deep shadowing is extremely uncommon.
91 for (Decl *D = II->getFETokenInfo<Decl>(); D; D = D->getNext())
92 if (D->getIdentifierNamespace() == NS)
93 return D;
94 return 0;
95}
96
97
Chris Lattnere168f762006-11-10 05:29:30 +000098Action::DeclTy *
99Sema::ParseDeclarator(Scope *S, Declarator &D, ExprTy *Init,
100 DeclTy *LastInGroup) {
101 IdentifierInfo *II = D.getIdentifier();
Chris Lattner302b4be2006-11-19 02:31:38 +0000102
Chris Lattner18b19622007-01-22 07:39:13 +0000103 if (Decl *PrevDecl = LookupScopedDecl(II, Decl::IDNS_Ordinary)) {
Chris Lattner302b4be2006-11-19 02:31:38 +0000104 // TODO: CHECK FOR CONFLICTS, multiple decls with same name in one scope.
Chris Lattner99d31772007-01-21 22:37:37 +0000105 if (S->isDeclScope(PrevDecl)) {
106 // TODO: This is totally simplistic. It should handle merging functions
107 // together etc, merging extern int X; int X; ...
108 Diag(D.getIdentifierLoc(), diag::err_redefinition, II->getName());
109 Diag(PrevDecl->getLocation(), diag::err_previous_definition);
110 }
Chris Lattner302b4be2006-11-19 02:31:38 +0000111 }
Chris Lattnere168f762006-11-10 05:29:30 +0000112
113 Decl *New;
Chris Lattner2114d5e2006-12-04 07:40:24 +0000114 if (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef)
Chris Lattner18b19622007-01-22 07:39:13 +0000115 New = ParseTypedefDecl(S, D);
Chris Lattner2114d5e2006-12-04 07:40:24 +0000116 else if (D.isFunctionDeclarator())
Chris Lattner18b19622007-01-22 07:39:13 +0000117 New = new FunctionDecl(D.getIdentifierLoc(), II, GetTypeForDeclarator(D,S));
Chris Lattnere168f762006-11-10 05:29:30 +0000118 else
Chris Lattner18b19622007-01-22 07:39:13 +0000119 New = new VarDecl(D.getIdentifierLoc(), II, GetTypeForDeclarator(D, S));
Chris Lattnere168f762006-11-10 05:29:30 +0000120
Chris Lattner302b4be2006-11-19 02:31:38 +0000121 if (!New) return 0;
122
123
Chris Lattnere168f762006-11-10 05:29:30 +0000124 // If this has an identifier, add it to the scope stack.
125 if (II) {
Chris Lattner18b19622007-01-22 07:39:13 +0000126 New->setNext(II->getFETokenInfo<Decl>());
Chris Lattnere168f762006-11-10 05:29:30 +0000127 II->setFETokenInfo(New);
Chris Lattner99d31772007-01-21 22:37:37 +0000128 S->AddDecl(New);
Chris Lattnere168f762006-11-10 05:29:30 +0000129 }
130
131 // If this is a top-level decl that is chained to some other (e.g. int A,B,C;)
132 // remember this in the LastInGroupList list.
133 if (LastInGroup && S->getParent() == 0)
134 LastInGroupList.push_back((Decl*)LastInGroup);
135
136 return New;
137}
138
Chris Lattnerc5cdf4d2007-01-21 07:42:07 +0000139VarDecl *
140Sema::ParseParamDeclarator(DeclaratorChunk &FTI, unsigned ArgNo,
141 Scope *FnScope) {
142 const DeclaratorChunk::ParamInfo &PI = FTI.Fun.ArgInfo[ArgNo];
Chris Lattner200bdc32006-11-19 02:43:37 +0000143
Chris Lattnerc5cdf4d2007-01-21 07:42:07 +0000144 IdentifierInfo *II = PI.Ident;
Chris Lattnerc284e9b2007-01-23 05:14:32 +0000145 // TODO: CHECK FOR CONFLICTS, multiple decls with same name in one scope.
146 // Can this happen for params? We already checked that they don't conflict
147 // among each other. Here they can only shadow globals, which is ok.
Chris Lattner18b19622007-01-22 07:39:13 +0000148 if (Decl *PrevDecl = LookupScopedDecl(II, Decl::IDNS_Ordinary)) {
Chris Lattnerc5cdf4d2007-01-21 07:42:07 +0000149
Chris Lattnerc5cdf4d2007-01-21 07:42:07 +0000150 }
151
Chris Lattner18b19622007-01-22 07:39:13 +0000152 VarDecl *New = new VarDecl(PI.IdentLoc, II, static_cast<Type*>(PI.TypeInfo));
Chris Lattnerc5cdf4d2007-01-21 07:42:07 +0000153
154 // If this has an identifier, add it to the scope stack.
155 if (II) {
Chris Lattner18b19622007-01-22 07:39:13 +0000156 New->setNext(II->getFETokenInfo<Decl>());
Chris Lattnerc5cdf4d2007-01-21 07:42:07 +0000157 II->setFETokenInfo(New);
Chris Lattner99d31772007-01-21 22:37:37 +0000158 FnScope->AddDecl(New);
Chris Lattnerc5cdf4d2007-01-21 07:42:07 +0000159 }
Chris Lattner229ce602006-11-21 01:21:07 +0000160
Chris Lattnerc5cdf4d2007-01-21 07:42:07 +0000161 return New;
162}
163
164
165Sema::DeclTy *Sema::ParseStartOfFunctionDef(Scope *FnBodyScope, Declarator &D) {
Chris Lattner229ce602006-11-21 01:21:07 +0000166 assert(CurFunctionDecl == 0 && "Function parsing confused");
Chris Lattner5c5fbcc2006-12-03 08:41:30 +0000167 assert(D.getTypeObject(0).Kind == DeclaratorChunk::Function &&
168 "Not a function declarator!");
169 DeclaratorChunk::FunctionTypeInfo &FTI = D.getTypeObject(0).Fun;
170
171 // Verify 6.9.1p6: 'every identifier in the identifier list shall be declared'
172 // for a K&R function.
173 if (!FTI.hasPrototype) {
174 for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i) {
175 if (FTI.ArgInfo[i].TypeInfo == 0) {
176 Diag(FTI.ArgInfo[i].IdentLoc, diag::err_param_not_declared,
177 FTI.ArgInfo[i].Ident->getName());
178 // Implicitly declare the argument as type 'int' for lack of a better
179 // type.
180 FTI.ArgInfo[i].TypeInfo = Context.IntTy.getAsOpaquePtr();
181 }
182 }
183
184 // Since this is a function definition, act as though we have information
185 // about the arguments.
186 FTI.hasPrototype = true;
Chris Lattner2114d5e2006-12-04 07:40:24 +0000187 } else {
188 // FIXME: Diagnose arguments without names in C.
189
Chris Lattner5c5fbcc2006-12-03 08:41:30 +0000190 }
191
Chris Lattnerc5cdf4d2007-01-21 07:42:07 +0000192 Scope *GlobalScope = FnBodyScope->getParent();
193
194 FunctionDecl *FD =
195 static_cast<FunctionDecl*>(ParseDeclarator(GlobalScope, D, 0, 0));
Chris Lattner229ce602006-11-21 01:21:07 +0000196 CurFunctionDecl = FD;
Chris Lattner2114d5e2006-12-04 07:40:24 +0000197
Chris Lattnerc5cdf4d2007-01-21 07:42:07 +0000198 // Create Decl objects for each parameter, adding them to the FunctionDecl.
199 SmallVector<VarDecl*, 16> Params;
Chris Lattnerf61c8a82007-01-21 19:04:43 +0000200
201 // Check for C99 6.7.5.3p10 - foo(void) is a non-varargs function that takes
202 // no arguments, not a function that takes a single void argument.
203 if (FTI.NumArgs == 1 && !FTI.isVariadic && FTI.ArgInfo[0].Ident == 0 &&
204 FTI.ArgInfo[0].TypeInfo == Context.VoidTy.getAsOpaquePtr()) {
Chris Lattner99d31772007-01-21 22:37:37 +0000205 // empty arg list, don't push any params.
Chris Lattnerf61c8a82007-01-21 19:04:43 +0000206 } else {
207 for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i)
208 Params.push_back(ParseParamDeclarator(D.getTypeObject(0), i,FnBodyScope));
209 }
Chris Lattner2114d5e2006-12-04 07:40:24 +0000210
Chris Lattnerc5cdf4d2007-01-21 07:42:07 +0000211 FD->setParams(&Params[0], Params.size());
Chris Lattner2114d5e2006-12-04 07:40:24 +0000212
Chris Lattnere168f762006-11-10 05:29:30 +0000213 return FD;
214}
215
Chris Lattner229ce602006-11-21 01:21:07 +0000216Sema::DeclTy *Sema::ParseFunctionDefBody(DeclTy *D, StmtTy *Body) {
217 FunctionDecl *FD = static_cast<FunctionDecl*>(D);
218 FD->setBody((Stmt*)Body);
219
220 assert(FD == CurFunctionDecl && "Function parsing confused");
221 CurFunctionDecl = 0;
222 return FD;
223}
224
225
Chris Lattnerac18be92006-11-20 06:49:47 +0000226/// ImplicitlyDefineFunction - An undeclared identifier was used in a function
227/// call, forming a call to an implicitly defined function (per C99 6.5.1p2).
228Decl *Sema::ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II,
229 Scope *S) {
230 if (getLangOptions().C99) // Extension in C99.
231 Diag(Loc, diag::ext_implicit_function_decl, II.getName());
232 else // Legal in C90, but warn about it.
233 Diag(Loc, diag::warn_implicit_function_decl, II.getName());
234
235 // FIXME: handle stuff like:
236 // void foo() { extern float X(); }
237 // void bar() { X(); } <-- implicit decl for X in another scope.
238
239 // Set a Declarator for the implicit definition: int foo();
Chris Lattner353f5742006-11-28 04:50:12 +0000240 const char *Dummy;
Chris Lattnerac18be92006-11-20 06:49:47 +0000241 DeclSpec DS;
Chris Lattnerb20e8942006-11-28 05:30:29 +0000242 bool Error = DS.SetTypeSpecType(DeclSpec::TST_int, Loc, Dummy);
Chris Lattner353f5742006-11-28 04:50:12 +0000243 assert(!Error && "Error setting up implicit decl!");
Chris Lattnerac18be92006-11-20 06:49:47 +0000244 Declarator D(DS, Declarator::BlockContext);
Chris Lattnercbc426d2006-12-02 06:43:02 +0000245 D.AddTypeInfo(DeclaratorChunk::getFunction(false, false, 0, 0, Loc));
Chris Lattnerac18be92006-11-20 06:49:47 +0000246 D.SetIdentifier(&II, Loc);
247
248 Decl *Result = static_cast<Decl*>(ParseDeclarator(S, D, 0, 0));
249
250 // Visit this implicit declaration like any other top-level form.
251 LastInGroupList.push_back(Result);
252 return Result;
253}
254
Chris Lattner302b4be2006-11-19 02:31:38 +0000255
Chris Lattner18b19622007-01-22 07:39:13 +0000256Decl *Sema::ParseTypedefDecl(Scope *S, Declarator &D) {
Chris Lattnerda8aa7b2006-11-19 23:12:30 +0000257 assert(D.getIdentifier() && "Wrong callback for declspec withotu declarator");
Chris Lattner302b4be2006-11-19 02:31:38 +0000258
Chris Lattner5ca17df2006-11-19 23:32:49 +0000259 TypeRef T = GetTypeForDeclarator(D, S);
Chris Lattner0d8b1a12006-11-20 04:34:45 +0000260 if (T.isNull()) return 0;
261
Chris Lattner18b19622007-01-22 07:39:13 +0000262 // Scope manipulation handled by caller.
263 return new TypedefDecl(D.getIdentifierLoc(), D.getIdentifier(), T);
Chris Lattnere168f762006-11-10 05:29:30 +0000264}
265
Chris Lattner18b19622007-01-22 07:39:13 +0000266
Chris Lattner1300fb92007-01-23 23:42:53 +0000267/// ParseTag - This is invoked when we see 'struct foo' or 'struct {'. In the
268/// former case, Name will be non-null. In the later case, Name will be null.
269/// TagType indicates what kind of tag this is. TK indicates whether this is a
270/// reference/declaration/definition of a tag.
Chris Lattner7b9ace62007-01-23 20:11:08 +0000271Sema::DeclTy *Sema::ParseTag(Scope *S, unsigned TagType, TagKind TK,
Chris Lattnerf34c4da2007-01-23 04:08:05 +0000272 SourceLocation KWLoc, IdentifierInfo *Name,
273 SourceLocation NameLoc) {
Chris Lattner8799cf22007-01-23 01:57:16 +0000274 // If this is a use of an existing tag, it must have a name.
Chris Lattner7b9ace62007-01-23 20:11:08 +0000275 assert((Name != 0 || TK == TK_Definition) &&
276 "Nameless record must be a definition!");
Chris Lattner8799cf22007-01-23 01:57:16 +0000277
Chris Lattnerf34c4da2007-01-23 04:08:05 +0000278 Decl::Kind Kind;
Chris Lattnerbf0b7982007-01-23 04:27:41 +0000279 switch (TagType) {
Chris Lattnerf34c4da2007-01-23 04:08:05 +0000280 default: assert(0 && "Unknown tag type!");
Chris Lattnerbf0b7982007-01-23 04:27:41 +0000281 case DeclSpec::TST_struct: Kind = Decl::Struct; break;
282 case DeclSpec::TST_union: Kind = Decl::Union; break;
283//case DeclSpec::TST_class: Kind = Decl::Class; break;
284 case DeclSpec::TST_enum: Kind = Decl::Enum; break;
Chris Lattnerf34c4da2007-01-23 04:08:05 +0000285 }
Chris Lattner7e783a12007-01-23 02:05:42 +0000286
Chris Lattner18b19622007-01-22 07:39:13 +0000287 // If this is a named struct, check to see if there was a previous forward
288 // declaration or definition.
Chris Lattner7b9ace62007-01-23 20:11:08 +0000289 if (TagDecl *PrevDecl =
290 dyn_cast_or_null<TagDecl>(LookupScopedDecl(Name, Decl::IDNS_Tag))) {
Chris Lattner8799cf22007-01-23 01:57:16 +0000291
292 // If this is a use of a previous tag, or if the tag is already declared in
293 // the same scope (so that the definition/declaration completes or
294 // rementions the tag), reuse the decl.
Chris Lattner7b9ace62007-01-23 20:11:08 +0000295 if (TK == TK_Reference || S->isDeclScope(PrevDecl)) {
Chris Lattner7e783a12007-01-23 02:05:42 +0000296 // Make sure that this wasn't declared as an enum and now used as a struct
297 // or something similar.
298 if (PrevDecl->getKind() != Kind) {
Chris Lattnerf34c4da2007-01-23 04:08:05 +0000299 Diag(KWLoc, diag::err_use_with_wrong_tag, Name->getName());
Chris Lattner7e783a12007-01-23 02:05:42 +0000300 Diag(PrevDecl->getLocation(), diag::err_previous_use);
301 }
Chris Lattner7b9ace62007-01-23 20:11:08 +0000302
303 // If this is a use or a forward declaration, we're good.
304 if (TK != TK_Definition)
305 return PrevDecl;
Chris Lattnerf34c4da2007-01-23 04:08:05 +0000306
Chris Lattner7b9ace62007-01-23 20:11:08 +0000307 // Diagnose attempts to redefine a tag.
308 if (PrevDecl->isDefinition()) {
309 Diag(NameLoc, diag::err_redefinition, Name->getName());
310 Diag(PrevDecl->getLocation(), diag::err_previous_definition);
311 // If this is a redefinition, recover by making this struct be
312 // anonymous, which will make any later references get the previous
313 // definition.
314 Name = 0;
315 } else {
316 // Okay, this is definition of a previously declared or referenced tag.
317 // Move the location of the decl to be the definition site.
318 PrevDecl->setLocation(NameLoc);
Chris Lattner1300fb92007-01-23 23:42:53 +0000319 //PrevDecl->setDefinition(true);
Chris Lattner7b9ace62007-01-23 20:11:08 +0000320 return PrevDecl;
321 }
Chris Lattner8799cf22007-01-23 01:57:16 +0000322 }
Chris Lattnerf34c4da2007-01-23 04:08:05 +0000323 // If we get here, this is a definition of a new struct type in a nested
324 // scope, e.g. "struct foo; void bar() { struct foo; }", just create a new
325 // type.
Chris Lattner18b19622007-01-22 07:39:13 +0000326 }
327
Chris Lattnerbf0b7982007-01-23 04:27:41 +0000328 // If there is an identifier, use the location of the identifier as the
329 // location of the decl, otherwise use the location of the struct/union
330 // keyword.
331 SourceLocation Loc = NameLoc.isValid() ? NameLoc : KWLoc;
332
Chris Lattner18b19622007-01-22 07:39:13 +0000333 // Otherwise, if this is the first time we've seen this tag, create the decl.
Chris Lattner7b9ace62007-01-23 20:11:08 +0000334 TagDecl *New;
Chris Lattnerf34c4da2007-01-23 04:08:05 +0000335 if (Kind != Decl::Enum)
336 New = new RecordDecl(Kind, Loc, Name);
337 else
338 assert(0 && "Enum tags not implemented yet!");
Chris Lattner18b19622007-01-22 07:39:13 +0000339
Chris Lattner1300fb92007-01-23 23:42:53 +0000340 //if (TK == TK_Definition)
341 // New->setDefinition(true);
Chris Lattner7b9ace62007-01-23 20:11:08 +0000342
Chris Lattner18b19622007-01-22 07:39:13 +0000343 // If this has an identifier, add it to the scope stack.
344 if (Name) {
345 New->setNext(Name->getFETokenInfo<Decl>());
346 Name->setFETokenInfo(New);
347 S->AddDecl(New);
348 }
349
350 return New;
351}
Chris Lattner1300fb92007-01-23 23:42:53 +0000352
353/// ParseField - Each field of a struct/union/class is passed into this in order
354/// to create a FieldDecl object for it.
355Sema::DeclTy *Sema::ParseField(Scope *S, DeclTy *TagDecl,
356 SourceLocation DeclStart,
357 Declarator &D, ExprTy *BitfieldWidth) {
358 IdentifierInfo *II = D.getIdentifier();
359 Expr *BitWidth = (Expr*)BitfieldWidth;
360
361 SourceLocation Loc = DeclStart;
362 if (II) Loc = D.getIdentifierLoc();
363
364 if (BitWidth) {
365 // TODO: Validate.
366 assert(0 && "bitfields unimp");
367
368 // 6.7.2.1p3
369 // 6.7.2.1p4
370
371 } else {
372 // Not a bitfield.
373
374 // validate II.
375
376 }
377
378 return new FieldDecl(Loc, II, GetTypeForDeclarator(D, S));
379}
380
381void Sema::ParseRecordBody(SourceLocation RecLoc, DeclTy *RecDecl,
382 DeclTy **Fields, unsigned NumFields) {
383 TagDecl *Record = static_cast<TagDecl*>(RecDecl);
384 if (Record->isDefinition()) {
385 // Diagnose code like:
386 // struct S { struct S {} X; };
387 // We discover this when we complete the outer S. Reject and ignore the
388 // outer S.
389 Diag(Record->getLocation(), diag::err_nested_redefinition,
390 Record->getKindName());
391 Diag(RecLoc, diag::err_previous_definition);
392 return;
393 }
394
395 Record->setDefinition(true);
396}
397
398