This is an archive of the discontinued LLVM Phabricator instance.

[Parser] Emit descriptive diagnostic for misplaced pragma
ClosedPublic

Authored by sepavloff on Jul 18 2019, 9:47 AM.

Details

Summary

If a class or struct or union declaration contains a pragma that
is not valid in this context, compiler issues generic error like
"expected member name or ';' after declaration specifiers". With this
change the error tells that this pragma cannot appear in this declaration.

Event Timeline

sepavloff created this revision.Jul 18 2019, 9:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 18 2019, 9:47 AM
Herald added a subscriber: dexonsmith. · View Herald Transcript
rjmccall added inline comments.Jul 26 2019, 11:19 AM
clang/lib/Basic/TokenKinds.cpp
55 ↗(On Diff #210610)

The right way to do this is to make a PRAGMA_ANNOTATION macro in TokenKinds.def that defaults to ANNOTATION, like that file already does with e.g. CXX11_KEYWORD. But for future reference, there's also a StringRef::startsWith.

Updated patch

Move logically independent changes to separate patches.

rjmccall added inline comments.Jul 31 2019, 9:16 PM
clang/lib/Basic/TokenKinds.cpp
15 ↗(On Diff #212188)

This is no longer necessary, right?

sepavloff updated this revision to Diff 213023.Aug 2 2019, 5:42 AM

Updated patch

sepavloff marked 2 inline comments as done.Aug 2 2019, 5:43 AM
sepavloff added inline comments.
clang/lib/Basic/TokenKinds.cpp
15 ↗(On Diff #212188)

Sure, removed it.

rjmccall accepted this revision.Aug 2 2019, 8:03 AM

LGTM

This revision is now accepted and ready to land.Aug 2 2019, 8:03 AM
This revision was automatically updated to reflect the committed changes.
sepavloff marked an inline comment as done.
Herald added a project: Restricted Project. · View Herald TranscriptAug 4 2019, 3:08 AM