diff options
author | Douglas Gregor <dgregor@apple.com> | 2008-11-21 16:29:06 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2008-11-21 16:29:06 +0000 |
commit | 5d58c3a568b64df97ec16b992c7be07adfdf69e6 (patch) | |
tree | e7467478f47470a5d6f0692e12a92f6323233a6c /clang/lib/Sema/SemaDecl.cpp | |
parent | b7f4ce3de707c53bc0d2455f45de3a2f39bae25e (diff) | |
download | bcm5719-llvm-5d58c3a568b64df97ec16b992c7be07adfdf69e6.tar.gz bcm5719-llvm-5d58c3a568b64df97ec16b992c7be07adfdf69e6.zip |
Allow redeclaration of typedefs in C++
llvm-svn: 59822
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 7408507f234..0b05177dd37 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -344,7 +344,14 @@ TypedefDecl *Sema::MergeTypeDefDecl(TypedefDecl *New, Decl *OldD) { if (getLangOptions().Microsoft) return New; - // Redeclaration of a type is a constraint violation (6.7.2.3p1). + // C++ [dcl.typedef]p2: + // In a given non-class scope, a typedef specifier can be used to + // redefine the name of any type declared in that scope to refer + // to the type to which it already refers. + if (getLangOptions().CPlusPlus && !isa<CXXRecordDecl>(CurContext)) + return New; + + // In C, redeclaration of a type is a constraint violation (6.7.2.3p1). // Apparently GCC, Intel, and Sun all silently ignore the redeclaration if // *either* declaration is in a system header. The code below implements // this adhoc compatibility rule. FIXME: The following code will not |