Fix redefinition of typedefs of fixable variably-modified array types; should
fix an issue compiling <windows.h>.
llvm-svn: 110651
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index e6c5170..d94b8dd3 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -2332,16 +2332,10 @@
// Handle attributes prior to checking for duplicates in MergeVarDecl
ProcessDeclAttributes(S, NewTD, D);
- // Merge the decl with the existing one if appropriate. If the decl is
- // in an outer scope, it isn't the same thing.
- FilterLookupForScope(*this, Previous, DC, S, /*ConsiderLinkage*/ false);
- if (!Previous.empty()) {
- Redeclaration = true;
- MergeTypeDefDecl(NewTD, Previous);
- }
-
// C99 6.7.7p2: If a typedef name specifies a variably modified type
// then it shall have block scope.
+ // Note that variably modified types must be fixed before merging the decl so
+ // that redeclarations will match.
QualType T = NewTD->getUnderlyingType();
if (T->isVariablyModifiedType()) {
setFunctionHasBranchProtectedScope();
@@ -2365,6 +2359,14 @@
}
}
+ // Merge the decl with the existing one if appropriate. If the decl is
+ // in an outer scope, it isn't the same thing.
+ FilterLookupForScope(*this, Previous, DC, S, /*ConsiderLinkage*/ false);
+ if (!Previous.empty()) {
+ Redeclaration = true;
+ MergeTypeDefDecl(NewTD, Previous);
+ }
+
// If this is the C FILE type, notify the AST context.
if (IdentifierInfo *II = NewTD->getIdentifier())
if (!NewTD->isInvalidDecl() &&