summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2011-06-12 11:43:46 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2011-06-12 11:43:46 +0000
commit4a4beec7b0c4d29c5fa47b02cbac16f786fef2eb (patch)
tree94fbd29419885283842785dfb206219edad8acd5 /clang/lib/Sema/SemaDecl.cpp
parente4073e0ae119ea66c358483e2d96cb962b227b82 (diff)
downloadbcm5719-llvm-4a4beec7b0c4d29c5fa47b02cbac16f786fef2eb.tar.gz
bcm5719-llvm-4a4beec7b0c4d29c5fa47b02cbac16f786fef2eb.zip
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
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp8
1 files changed, 2 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 9446c0e8c03..a783575278f 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -5208,12 +5208,8 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init,
VarDecl *VDecl = dyn_cast<VarDecl>(RealDecl);
if (!VDecl) {
- if (getLangOptions().CPlusPlus &&
- RealDecl->getLexicalDeclContext()->isRecord() &&
- isa<NamedDecl>(RealDecl))
- Diag(RealDecl->getLocation(), diag::err_member_initialization);
- else
- Diag(RealDecl->getLocation(), diag::err_illegal_initializer);
+ assert(!isa<FieldDecl>(RealDecl) && "field init shouldn't get here");
+ Diag(RealDecl->getLocation(), diag::err_illegal_initializer);
RealDecl->setInvalidDecl();
return;
}
OpenPOWER on IntegriCloud