r227781 - Follow-up to r217302: Don't crash on ~A::A in a postfix expr suffix followed by '<'.
Nico Weber
nicolasweber at gmx.de
Sun Feb 1 21:33:50 PST 2015
Author: nico
Date: Sun Feb 1 23:33:50 2015
New Revision: 227781
URL: http://llvm.org/viewvc/llvm-project?rev=227781&view=rev
Log:
Follow-up to r217302: Don't crash on ~A::A in a postfix expr suffix followed by '<'.
This used to crash, complaining "ObjectType and scope specifier cannot coexist":
struct A { } b = b.~A::A <int>;
The only other caller of ParseOptionalCXXScopeSpecifier() that passes in a
non-empty ObjectType clears the ObjectType of the scope specifier comes back
non-empty (see the tok::period case in Parser::ParsePostfixExpressionSuffix()),
so do that here too.
Found by SLi's bot.
Modified:
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/test/Parser/cxx-class.cpp
Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=227781&r1=227780&r2=227781&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Sun Feb 1 23:33:50 2015
@@ -2521,6 +2521,8 @@ bool Parser::ParseUnqualifiedId(CXXScope
}
if (ParseOptionalCXXScopeSpecifier(SS, ObjectType, EnteringContext))
return true;
+ if (SS.isNotEmpty())
+ ObjectType = ParsedType();
if (Tok.isNot(tok::identifier) || NextToken().is(tok::coloncolon) ||
SS.isInvalid()) {
Diag(TildeLoc, diag::err_destructor_tilde_scope);
Modified: cfe/trunk/test/Parser/cxx-class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-class.cpp?rev=227781&r1=227780&r2=227781&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx-class.cpp (original)
+++ cfe/trunk/test/Parser/cxx-class.cpp Sun Feb 1 23:33:50 2015
@@ -174,6 +174,11 @@ namespace DtorErrors {
int I; // expected-note {{declared here}}
~I::I() {} // expected-error {{'I' is not a class, namespace, or enumeration}} expected-error {{'~' in destructor name should be after nested name specifier}}
};
+
+ struct T {};
+ T t1 = t1.T::~T<int>; // expected-error {{destructor name 'T' does not refer to a template}} expected-error {{expected '(' for function-style cast or type construction}} expected-error {{expected expression}}
+ // Emit the same diagnostic as for the previous case, plus something about ~.
+ T t2 = t2.~T::T<int>; // expected-error {{'~' in destructor name should be after nested name specifier}} expected-error {{destructor name 'T' does not refer to a template}} expected-error {{expected '(' for function-style cast or type construction}} expected-error {{expected expression}}
}
namespace BadFriend {
More information about the cfe-commits
mailing list