From 4a4beec7b0c4d29c5fa47b02cbac16f786fef2eb Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Sun, 12 Jun 2011 11:43:46 +0000 Subject: Don't assert on initialized typedef declarations in classes: struct { typedef int A = 0; }; According to the C++11 standard, this is not ill-formed, but does not have any ascribed meaning. We can't reasonably accept it, so treat it as ill-formed. Also switch C++ from an incorrect 'fields can only be initialized in constructors' diagnostic for this case to C's 'illegal initializer (only variables can be initialized)' llvm-svn: 132890 --- clang/lib/Parse/ParseDeclCXX.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'clang/lib/Parse/ParseDeclCXX.cpp') diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 51aa01091e7..640e50176bc 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -1830,7 +1830,9 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, } else { HasDeferredInitializer = !DeclaratorInfo.isFunctionDeclarator() && DeclaratorInfo.getDeclSpec().getStorageClassSpec() - != DeclSpec::SCS_static; + != DeclSpec::SCS_static && + DeclaratorInfo.getDeclSpec().getStorageClassSpec() + != DeclSpec::SCS_typedef; if (!HasDeferredInitializer) { SourceLocation EqualLoc; -- cgit v1.2.3