diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -648,18 +648,12 @@ // attributes as part of a statement in that case). That looks like a bug. if (!getLangOpts().CPlusPlus || Tok.is(tok::semi)) attrs.takeAllFrom(TempAttrs); - else if (isDeclarationStatement()) { + else { StmtVector Stmts; - // FIXME: We should do this whether or not we have a declaration - // statement, but that doesn't work correctly (because ProhibitAttributes - // can't handle GNU attributes), so only call it in the one case where - // GNU attributes are allowed. SubStmt = ParseStatementOrDeclarationAfterAttributes(Stmts, StmtCtx, nullptr, TempAttrs); if (!TempAttrs.empty() && !SubStmt.isInvalid()) SubStmt = Actions.ActOnAttributedStmt(TempAttrs, SubStmt.get()); - } else { - Diag(Tok, diag::err_expected_after) << "__attribute__" << tok::semi; } } diff --git a/clang/test/SemaCXX/warn-unused-label-error.cpp b/clang/test/SemaCXX/warn-unused-label-error.cpp --- a/clang/test/SemaCXX/warn-unused-label-error.cpp +++ b/clang/test/SemaCXX/warn-unused-label-error.cpp @@ -12,8 +12,8 @@ void g() { C: // unused label 'C' will not appear here because an error has occurred - __attribute__((unused)) - #pragma weak unused_local_static // expected-error {{expected ';' after __attribute__}} + __attribute__((unused)) // expected-error {{an attribute list cannot appear here}} + #pragma weak unused_local_static ; }