diff options
author | Nico Weber <nicolasweber@gmx.de> | 2015-02-18 05:19:40 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2015-02-18 05:19:40 +0000 |
commit | 4486d61c03c1fe9c84af63727bbed269d957e720 (patch) | |
tree | d3eca2d5a191a47f654b3cca26365f62ca38f69e /clang/lib/Sema/SemaDecl.cpp | |
parent | 90b1d152b5161ca87b6545da0a7134173cf7336f (diff) | |
download | bcm5719-llvm-4486d61c03c1fe9c84af63727bbed269d957e720.tar.gz bcm5719-llvm-4486d61c03c1fe9c84af63727bbed269d957e720.zip |
Port r163224 to C++.
The motivation is to fix a crash on
struct S {} s;
Foo S::~S() { s.~S(); }
What was happening here was that S::~S() was marked as invalid since its
return type is invalid, and as a consequence CheckFunctionDeclaration() wasn't
called and S::~S() didn't get merged into S's implicit destructor. This way,
the class ended up with two destructors, which confused the overload printer
when it suddenly had to print two possible destructors for `s.~S()`.
In addition to fixing the crash, this change also seems to improve diagnostics
in a few other places, see test changes.
Crash found by SLi's bot.
llvm-svn: 229639
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index ae18d9cbdb4..d351b4841f8 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -7418,7 +7418,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, D.setRedeclaration(CheckFunctionDeclaration(S, NewFD, Previous, isExplicitSpecialization)); else if (!Previous.empty()) - // Make graceful recovery from an invalid redeclaration. + // Recover gracefully from an invalid redeclaration. D.setRedeclaration(true); assert((NewFD->isInvalidDecl() || !D.isRedeclaration() || Previous.getResultKind() != LookupResult::FoundOverloaded) && @@ -7559,6 +7559,9 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, if (!NewFD->isInvalidDecl()) D.setRedeclaration(CheckFunctionDeclaration(S, NewFD, Previous, isExplicitSpecialization)); + else if (!Previous.empty()) + // Recover gracefully from an invalid redeclaration. + D.setRedeclaration(true); } assert((NewFD->isInvalidDecl() || !D.isRedeclaration() || |