From ced7617c3853d19ffa00a578e92ffd7c54b6c2fb Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 20 Mar 2020 18:44:13 -0700 Subject: [PATCH] PR45267: Don't reject pure-specifiers with escaped newlines in their '0' token. --- clang/lib/Parse/ParseDeclCXX.cpp | 2 +- clang/test/Parser/cxx-class.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 85dc4e3e706a..86a9a8208b2e 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -2670,7 +2670,7 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, auto &Zero = NextToken(); SmallString<8> Buffer; - if (Zero.isNot(tok::numeric_constant) || Zero.getLength() != 1 || + if (Zero.isNot(tok::numeric_constant) || PP.getSpelling(Zero, Buffer) != "0") return false; diff --git a/clang/test/Parser/cxx-class.cpp b/clang/test/Parser/cxx-class.cpp index e672c45068da..e73c8740a3ef 100644 --- a/clang/test/Parser/cxx-class.cpp +++ b/clang/test/Parser/cxx-class.cpp @@ -37,7 +37,9 @@ public: virtual int vf5a(){0;}; // function definition, expected-warning {{unused}} virtual int vf6()(0); // expected-error +{{}} expected-note +{{}} virtual int vf7() = { 0 }; // expected-error {{does not look like a pure-specifier}} - + virtual int PR45267() = \ + 0; // ok, despite escaped newline + private: int x,f(),y,g(); inline int h();