summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-02-10 17:16:49 +0000
committerDouglas Gregor <dgregor@apple.com>2010-02-10 17:16:49 +0000
commit2fbe558cfe8de9e6c3fb1a8728e91df3d16d0413 (patch)
treed3c7f32872a510ba108c473bb4640f0df737387a /clang/lib/AST
parent4a618827de7c540c68685789d1eb9b2b50cdc33f (diff)
downloadbcm5719-llvm-2fbe558cfe8de9e6c3fb1a8728e91df3d16d0413.tar.gz
bcm5719-llvm-2fbe558cfe8de9e6c3fb1a8728e91df3d16d0413.zip
Teach AST merging that variables with incomplete array types can be
merged with variables of constant array types. Also, make sure that we call DiagnosticClient's BeginSourceFile/EndSourceFile, so that it has a LangOptions to work with. llvm-svn: 95782
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/ASTImporter.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 75917cf04c8..9fb695e4e10 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -500,6 +500,33 @@ Decl *ASTNodeImporter::VisitVarDecl(VarDecl *D) {
break;
}
+ if (const IncompleteArrayType *FoundArray
+ = Importer.getToContext().getAsIncompleteArrayType(
+ FoundVar->getType())) {
+ if (const ConstantArrayType *TArray
+ = Importer.getToContext().getAsConstantArrayType(T)) {
+ if (Importer.getToContext().typesAreCompatible(
+ TArray->getElementType(),
+ FoundArray->getElementType())) {
+ FoundVar->setType(T);
+ MergeWithVar = FoundVar;
+ break;
+ }
+ }
+ } else if (const IncompleteArrayType *TArray
+ = Importer.getToContext().getAsIncompleteArrayType(T)) {
+ if (const ConstantArrayType *FoundArray
+ = Importer.getToContext().getAsConstantArrayType(
+ FoundVar->getType())) {
+ if (Importer.getToContext().typesAreCompatible(
+ TArray->getElementType(),
+ FoundArray->getElementType())) {
+ MergeWithVar = FoundVar;
+ break;
+ }
+ }
+ }
+
Importer.ToDiag(Loc, diag::err_odr_variable_type_inconsistent)
<< Name << T << FoundVar->getType();
Importer.ToDiag(FoundVar->getLocation(), diag::note_odr_value_here)
OpenPOWER on IntegriCloud