From 5d58c3a568b64df97ec16b992c7be07adfdf69e6 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 21 Nov 2008 16:29:06 +0000 Subject: Allow redeclaration of typedefs in C++ llvm-svn: 59822 --- clang/lib/Sema/SemaDecl.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'clang/lib/Sema/SemaDecl.cpp') 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(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 -- cgit v1.2.3