summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseDecl.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-02-19 23:47:15 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-02-19 23:47:15 +0000
commit4c96e99235b32b594abaf93e5c16c81aae7acb3c (patch)
tree4d1dd07e61150390848ff4436b8e68c492b076cd /clang/lib/Parse/ParseDecl.cpp
parent9d6f7037ba7067b850a2abaf65be0b8d08ff134c (diff)
downloadbcm5719-llvm-4c96e99235b32b594abaf93e5c16c81aae7acb3c.tar.gz
bcm5719-llvm-4c96e99235b32b594abaf93e5c16c81aae7acb3c.zip
PR15300: Support C++11 attributes on base-specifiers. We don't support any such
attributes yet, so just issue the appropriate diagnostics. Also generalize the fixit for attributes-in-the-wrong-place code and reuse it here, if attributes are placed after the access-specifier or 'virtual' in a base specifier. llvm-svn: 175575
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r--clang/lib/Parse/ParseDecl.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 0dd1e0a6f42..cc47ee1d905 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -1144,6 +1144,25 @@ bool Parser::DiagnoseProhibitedCXX11Attribute() {
llvm_unreachable("All cases handled above.");
}
+/// DiagnoseMisplacedCXX11Attribute - We have found the opening square brackets
+/// of a C++11 attribute-specifier in a location where an attribute is not
+/// permitted, but we know where the attributes ought to be written. Parse them
+/// anyway, and provide a fixit moving them to the right place.
+void Parser::DiagnoseMisplacedCXX11Attribute(ParsedAttributesWithRange &Attrs,
+ SourceLocation CorrectLocation) {
+ assert((Tok.is(tok::l_square) && NextToken().is(tok::l_square)) ||
+ Tok.is(tok::kw_alignas));
+
+ // Consume the attributes.
+ SourceLocation Loc = Tok.getLocation();
+ ParseCXX11Attributes(Attrs);
+ CharSourceRange AttrRange(SourceRange(Loc, Attrs.Range.getEnd()), true);
+
+ Diag(Loc, diag::err_attributes_not_allowed)
+ << FixItHint::CreateInsertionFromRange(CorrectLocation, AttrRange)
+ << FixItHint::CreateRemoval(AttrRange);
+}
+
void Parser::DiagnoseProhibitedAttributes(ParsedAttributesWithRange &attrs) {
Diag(attrs.Range.getBegin(), diag::err_attributes_not_allowed)
<< attrs.Range;
OpenPOWER on IntegriCloud