summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-01-09 15:36:04 +0000
committerDouglas Gregor <dgregor@apple.com>2012-01-09 15:36:04 +0000
commitdbd93bfc2df559c072e7a7ff7a9b0b5dc61b2630 (patch)
treec002e1f6a1398ff6af8bab62c421e53a41964449 /clang/lib
parent3732fa5417ceb148d2e5f00fae844180bfeb2efa (diff)
downloadbcm5719-llvm-dbd93bfc2df559c072e7a7ff7a9b0b5dc61b2630.tar.gz
bcm5719-llvm-dbd93bfc2df559c072e7a7ff7a9b0b5dc61b2630.zip
Always allow redefinition of typedefs when modules are enabled. This
is important because it's fairly common for headers (especially system headers) to want to provide only those typedefs needed for that particular header, based on some guard macro, e.g., #ifndef _SIZE_T #define _SIZE_T typedef long size_t; #endif which is repeated in a number of headers. The guard macro protects against duplicate definitions. However, this means that only the first occurrence of this pattern actually defines size_t, so the submodule corresponding to this header has the only visible definition. If a user then imports a different submodule from the same module, size_t will be known but not visible, and therefore cannot be used. By allowing redefinition of typedefs, each header that wants to define size_t can do so independently, so it will be available in the corresponding submodules. llvm-svn: 147775
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 54f953d3437..b541e7d9e71 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -1509,6 +1509,10 @@ void Sema::MergeTypedefNameDecl(TypedefNameDecl *New, LookupResult &OldDecls) {
return New->setInvalidDecl();
}
+ // Modules always permit redefinition of typedefs.
+ if (getLangOptions().Modules)
+ return;
+
// If we have a redefinition of a typedef in C, emit a warning. This warning
// is normally mapped to an error, but can be controlled with
// -Wtypedef-redefinition. If either the original or the redefinition is
OpenPOWER on IntegriCloud