From 1600e2452113ec9979e866525c86b4ab83d866ff Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 16 Apr 2019 00:47:45 +0000 Subject: [PATCH] PR41192: fix cases where "missing ';' after class" error would incorrectly fire. llvm-svn: 358467 --- clang/lib/Parse/ParseDeclCXX.cpp | 2 ++ clang/test/CXX/cpp/cpp.module/p2.cpp | 5 ++--- clang/test/Parser/cxx-class.cpp | 11 +++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index de481e887935..9159f4d6826f 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -1248,9 +1248,11 @@ bool Parser::isValidAfterTypeSpecifier(bool CouldBeBitfield) { case tok::ampamp: // struct foo {...} && R = ... case tok::identifier: // struct foo {...} V ; case tok::r_paren: //(struct foo {...} ) {4} + case tok::coloncolon: // struct foo {...} :: a::b; case tok::annot_cxxscope: // struct foo {...} a:: b; case tok::annot_typename: // struct foo {...} a ::b; case tok::annot_template_id: // struct foo {...} a ::b; + case tok::kw_decltype: // struct foo {...} decltype (a)::b; case tok::l_paren: // struct foo {...} ( x); case tok::comma: // __builtin_offsetof(struct foo{...} , case tok::kw_operator: // struct foo operator ++() {...} diff --git a/clang/test/CXX/cpp/cpp.module/p2.cpp b/clang/test/CXX/cpp/cpp.module/p2.cpp index ae68a508a020..d5bf4fa1a653 100644 --- a/clang/test/CXX/cpp/cpp.module/p2.cpp +++ b/clang/test/CXX/cpp/cpp.module/p2.cpp @@ -13,10 +13,9 @@ template<> struct import<0> { }; // OK, not an import-declaration. -// FIXME: This is valid, see PR41192 -struct A {} // FIXME expected-error {{expected ';'}} +struct A {} ::import -::a; // FIXME expected-error {{requires a type specifier}} +::a; // This is invalid: the tokens after 'import' are a header-name, so cannot be // parsed as a template-argument-list. diff --git a/clang/test/Parser/cxx-class.cpp b/clang/test/Parser/cxx-class.cpp index 3cc006af23dc..fe9c1ac95b44 100644 --- a/clang/test/Parser/cxx-class.cpp +++ b/clang/test/Parser/cxx-class.cpp @@ -272,6 +272,17 @@ class BadExceptionSpec { )); }; +namespace PR41192 { +extern struct A a; +struct A {} ::PR41192::a; // ok, no missing ';' here expected-warning {{extra qualification}} + +#if __cplusplus >= 201103L +struct C; +struct D { static C c; }; +struct C {} decltype(D())::c; // expected-error {{'decltype' cannot be used to name a declaration}} +#endif +} + // PR11109 must appear at the end of the source file class pr11109r3 { // expected-note{{to match this '{'}} public // expected-error{{expected ':'}} expected-error{{expected '}'}} expected-error{{expected ';' after class}}