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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95782 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp
index 75917cf..9fb695e 100644
--- a/lib/AST/ASTImporter.cpp
+++ b/lib/AST/ASTImporter.cpp
@@ -500,6 +500,33 @@
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)