summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2012-02-14 09:00:46 +0000
committerDavid Blaikie <dblaikie@gmail.com>2012-02-14 09:00:46 +0000
commitcdd91dbe9f08fcd481f0962ff7c55ae5761a6356 (patch)
tree9d4e03ab08c3e9048d8c57d1bcc2e6698f0c2b10
parentcfad98f745e210ba3211bd62b7fd362061449ee2 (diff)
downloadbcm5719-llvm-cdd91dbe9f08fcd481f0962ff7c55ae5761a6356.tar.gz
bcm5719-llvm-cdd91dbe9f08fcd481f0962ff7c55ae5761a6356.zip
Fix crash-on-invalid for 'operator int[]()' in C++11.
Signed off by Richard Smith. llvm-svn: 150464
-rw-r--r--clang/lib/Parse/ParseDeclCXX.cpp7
-rw-r--r--clang/test/SemaCXX/member-init.cpp3
2 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index cc0cf15e739..6213824cae3 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -1989,11 +1989,12 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
// declarator is followed by an initializer.
//
// A brace-or-equal-initializer for a member-declarator is not an
- // initializer in the gramamr, so this is ill-formed.
+ // initializer in the grammar, so this is ill-formed.
Diag(Tok, diag::err_incomplete_array_member_init);
SkipUntil(tok::comma, true, true);
- // Avoid later warnings about a class member of incomplete type.
- ThisDecl->setInvalidDecl();
+ if (ThisDecl)
+ // Avoid later warnings about a class member of incomplete type.
+ ThisDecl->setInvalidDecl();
} else
ParseCXXNonStaticMemberInitializer(ThisDecl);
} else if (HasInitializer) {
diff --git a/clang/test/SemaCXX/member-init.cpp b/clang/test/SemaCXX/member-init.cpp
index 819c8d13db8..c93c85bbf89 100644
--- a/clang/test/SemaCXX/member-init.cpp
+++ b/clang/test/SemaCXX/member-init.cpp
@@ -29,6 +29,9 @@ const int C = 0, D = 0;
struct S {
int as[] = { decltype(x)::B<C, D>(0) }; // expected-error {{array bound cannot be deduced from an in-class initializer}}
T<sizeof(as) / sizeof(int)> x; // expected-error {{requires a type specifier}}
+ // test that we handle invalid array bound deductions without crashing when the declarator name is itself invalid
+ operator int[](){}; // expected-error {{'operator int' cannot be the name of a variable or data member}} \
+ // expected-error {{array bound cannot be deduced from an in-class initializer}}
};
struct ThrowCtor { ThrowCtor(int) noexcept(false); };
OpenPOWER on IntegriCloud