aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-11-21 16:29:06 +0000
committerDouglas Gregor <dgregor@apple.com>2008-11-21 16:29:06 +0000
commitbbe2743b0259e6c8b053b601bfd768dd49c8143a (patch)
treed432ed1f9e46ac272c76cec83c3f2166a5aa0f7c /lib/Sema/SemaDecl.cpp
parentd67777662b7aac5a007513ba1fe25cb60e13fc3d (diff)
Allow redeclaration of typedefs in C++
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59822 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 7408507f23..0b05177dd3 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/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