diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-03-08 00:32:55 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-03-08 00:32:55 +0000 |
commit | 4f902c7eccd47cc3e1d0ceebca3025406a2e5fa7 (patch) | |
tree | f4f111a17e5cb2aa89e7050bd5c8ef41e30bc2f2 /clang/lib/Sema/SemaDeclAttr.cpp | |
parent | 12350a8e133caefd43d1bc1d18baa66ba5202a3d (diff) | |
download | bcm5719-llvm-4f902c7eccd47cc3e1d0ceebca3025406a2e5fa7.tar.gz bcm5719-llvm-4f902c7eccd47cc3e1d0ceebca3025406a2e5fa7.zip |
P0188R1: add support for standard [[fallthrough]] attribute. This is almost
exactly the same as clang's existing [[clang::fallthrough]] attribute, which
has been updated to have the same semantics. The one significant difference
is that [[fallthrough]] is ill-formed if it's not used immediately before a
switch label (even when -Wimplicit-fallthrough is disabled). To support that,
we now build a CFG of any function that uses a '[[fallthrough]];' statement
to check.
In passing, fix some bugs with our support for statement attributes -- in
particular, diagnose their use on declarations, rather than asserting.
llvm-svn: 262881
Diffstat (limited to 'clang/lib/Sema/SemaDeclAttr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index ce78ab00926..1fca27f8b95 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -2467,7 +2467,7 @@ static void handleWarnUnusedResult(Sema &S, Decl *D, const AttributeList &Attr) // about using it as an extension. if (!S.getLangOpts().CPlusPlus1z && Attr.isCXX11Attribute() && !Attr.getScopeName()) - S.Diag(Attr.getLoc(), diag::ext_nodiscard_attr_is_a_cxx1z_extension); + S.Diag(Attr.getLoc(), diag::ext_cxx1z_attr) << Attr.getName(); D->addAttr(::new (S.Context) WarnUnusedResultAttr(Attr.getRange(), S.Context, @@ -5072,7 +5072,7 @@ static void handleDeprecatedAttr(Sema &S, Decl *D, const AttributeList &Attr) { if (!S.getLangOpts().CPlusPlus14) if (Attr.isCXX11Attribute() && !(Attr.hasScope() && Attr.getScopeName()->isStr("gnu"))) - S.Diag(Attr.getLoc(), diag::ext_deprecated_attr_is_a_cxx14_extension); + S.Diag(Attr.getLoc(), diag::ext_cxx14_attr) << Attr.getName(); handleAttrWithMessage<DeprecatedAttr>(S, D, Attr); } @@ -5234,8 +5234,13 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, switch (Attr.getKind()) { default: - // Type attributes are handled elsewhere; silently move on. - assert(Attr.isTypeAttr() && "Non-type attribute not handled"); + if (!Attr.isStmtAttr()) { + // Type attributes are handled elsewhere; silently move on. + assert(Attr.isTypeAttr() && "Non-type attribute not handled"); + break; + } + S.Diag(Attr.getLoc(), diag::err_stmt_attribute_invalid_on_decl) + << Attr.getName() << D->getLocation(); break; case AttributeList::AT_Interrupt: handleInterruptAttr(S, D, Attr); |