<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Mar 8, 2016 at 1:49 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">On Tue, Mar 8, 2016 at 9:05 AM, Nico Weber <<a href="mailto:thakis@chromium.org">thakis@chromium.org</a>> wrote:<br>
> This causes clang to warn on<br>
><br>
> default: assert (false); HB_FALLTHROUGH;<br>
<br>
</span>What follows this? (A case label?) What warning is being produced?<br></blockquote><div><br></div><div>A case label. Full snippet: <a href="https://code.google.com/p/chromium/codesearch#chromium/src/third_party/harfbuzz-ng/src/hb-ot-shape-complex-thai.cc&l=142">https://code.google.com/p/chromium/codesearch#chromium/src/third_party/harfbuzz-ng/src/hb-ot-shape-complex-thai.cc&l=142</a></div><div><br></div><div>Full warning (from <a href="https://build.chromium.org/p/chromium.fyi/builders/ClangToTMac%20%28dbg%29/builds/4497/steps/compile/logs/stdio">https://build.chromium.org/p/chromium.fyi/builders/ClangToTMac%20%28dbg%29/builds/4497/steps/compile/logs/stdio</a>):</div><div><br></div><div><div>../../third_party/harfbuzz-ng/src/hb-ot-shape-complex-thai.cc:142:30: error: fallthrough annotation in unreachable code [-Werror,-Wimplicit-fallthrough]</div><div> default: assert (false); HB_FALLTHROUGH;</div><div> ^</div><div>../../third_party/harfbuzz-ng/src/hb-private.hh:140:26: note: expanded from macro 'HB_FALLTHROUGH'</div><div># define HB_FALLTHROUGH [[clang::fallthrough]]</div></div><div><br></div><div>As far as I know, we don't opt in to -Wimplicit-fallthrough (and I don't see a flag on the commandline of the failing compile; also available at the above link.)</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class=""><div class="h5"><br>
> The fallthrough needs to be there for release builds, but now it must not be<br>
> there for debug builds. I suppose this means projects now need an<br>
> UNREACHED_CASE macro that expands to assert(false) in debug and to<br>
> fallthrough in release (with clang; and to something else with other<br>
> compilers)?<br>
><br>
> On Mon, Mar 7, 2016 at 7:32 PM, Richard Smith via cfe-commits<br>
> <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br>
>><br>
>> Author: rsmith<br>
>> Date: Mon Mar 7 18:32:55 2016<br>
>> New Revision: 262881<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=262881&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=262881&view=rev</a><br>
>> Log:<br>
>> P0188R1: add support for standard [[fallthrough]] attribute. This is<br>
>> almost<br>
>> exactly the same as clang's existing [[clang::fallthrough]] attribute,<br>
>> which<br>
>> has been updated to have the same semantics. The one significant<br>
>> difference<br>
>> is that [[fallthrough]] is ill-formed if it's not used immediately before<br>
>> a<br>
>> switch label (even when -Wimplicit-fallthrough is disabled). To support<br>
>> that,<br>
>> we now build a CFG of any function that uses a '[[fallthrough]];'<br>
>> statement<br>
>> to check.<br>
>><br>
>> In passing, fix some bugs with our support for statement attributes -- in<br>
>> particular, diagnose their use on declarations, rather than asserting.<br>
>><br>
>> Modified:<br>
>> cfe/trunk/include/clang/AST/Attr.h<br>
>> cfe/trunk/include/clang/Basic/Attr.td<br>
>> cfe/trunk/include/clang/Basic/AttrDocs.td<br>
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>
>> cfe/trunk/include/clang/Sema/AttributeList.h<br>
>> cfe/trunk/include/clang/Sema/ScopeInfo.h<br>
>> cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp<br>
>> cfe/trunk/lib/Sema/AttributeList.cpp<br>
>> cfe/trunk/lib/Sema/SemaDeclAttr.cpp<br>
>> cfe/trunk/lib/Sema/SemaStmtAttr.cpp<br>
>> cfe/trunk/test/Analysis/cxx11-crashes.cpp<br>
>> cfe/trunk/test/PCH/Inputs/cxx11-statement-attributes.h<br>
>> cfe/trunk/test/PCH/cxx11-statement-attributes.cpp<br>
>> cfe/trunk/test/Parser/cxx0x-attributes.cpp<br>
>> cfe/trunk/test/SemaCXX/for-range-examples.cpp<br>
>> cfe/trunk/test/SemaCXX/generalized-deprecated.cpp<br>
>> cfe/trunk/test/SemaCXX/nodiscard.cpp<br>
>> cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-macro.cpp<br>
>> cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-per-method.cpp<br>
>> cfe/trunk/test/SemaCXX/switch-implicit-fallthrough.cpp<br>
>> cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp<br>
>> cfe/trunk/www/cxx_status.html<br>
>><br>
>> Modified: cfe/trunk/include/clang/AST/Attr.h<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=262881&r1=262880&r2=262881&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=262881&r1=262880&r2=262881&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- cfe/trunk/include/clang/AST/Attr.h (original)<br>
>> +++ cfe/trunk/include/clang/AST/Attr.h Mon Mar 7 18:32:55 2016<br>
>> @@ -118,6 +118,19 @@ public:<br>
>> bool duplicatesAllowed() const { return DuplicatesAllowed; }<br>
>> };<br>
>><br>
>> +class StmtAttr : public Attr {<br>
>> +protected:<br>
>> + StmtAttr(attr::Kind AK, SourceRange R, unsigned SpellingListIndex,<br>
>> + bool IsLateParsed, bool DuplicatesAllowed)<br>
>> + : Attr(AK, R, SpellingListIndex, IsLateParsed, DuplicatesAllowed)<br>
>> {}<br>
>> +<br>
>> +public:<br>
>> + static bool classof(const Attr *A) {<br>
>> + return A->getKind() >= attr::FirstStmtAttr &&<br>
>> + A->getKind() <= attr::LastStmtAttr;<br>
>> + }<br>
>> +};<br>
>> +<br>
>> class InheritableAttr : public Attr {<br>
>> protected:<br>
>> InheritableAttr(attr::Kind AK, SourceRange R, unsigned<br>
>> SpellingListIndex,<br>
>><br>
>> Modified: cfe/trunk/include/clang/Basic/Attr.td<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=262881&r1=262880&r2=262881&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=262881&r1=262880&r2=262881&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- cfe/trunk/include/clang/Basic/Attr.td (original)<br>
>> +++ cfe/trunk/include/clang/Basic/Attr.td Mon Mar 7 18:32:55 2016<br>
>> @@ -311,6 +311,9 @@ class TypeAttr : Attr {<br>
>> let ASTNode = 0;<br>
>> }<br>
>><br>
>> +/// A stmt attribute is not processed on a declaration or a type.<br>
>> +class StmtAttr : Attr;<br>
>> +<br>
>> /// An inheritable attribute is inherited by later redeclarations.<br>
>> class InheritableAttr : Attr;<br>
>><br>
>> @@ -738,8 +741,9 @@ def ExtVectorType : Attr {<br>
>> let Documentation = [Undocumented];<br>
>> }<br>
>><br>
>> -def FallThrough : Attr {<br>
>> - let Spellings = [CXX11<"clang", "fallthrough">];<br>
>> +def FallThrough : StmtAttr {<br>
>> + let Spellings = [CXX11<"", "fallthrough", 201503>,<br>
>> + CXX11<"clang", "fallthrough">];<br>
>> // let Subjects = [NullStmt];<br>
>> let Documentation = [FallthroughDocs];<br>
>> }<br>
>><br>
>> Modified: cfe/trunk/include/clang/Basic/AttrDocs.td<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=262881&r1=262880&r2=262881&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=262881&r1=262880&r2=262881&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- cfe/trunk/include/clang/Basic/AttrDocs.td (original)<br>
>> +++ cfe/trunk/include/clang/Basic/AttrDocs.td Mon Mar 7 18:32:55 2016<br>
>> @@ -756,9 +756,10 @@ potentially-evaluated discarded-value ex<br>
>><br>
>> def FallthroughDocs : Documentation {<br>
>> let Category = DocCatStmt;<br>
>> + let Heading = "fallthrough, clang::fallthrough";<br>
>> let Content = [{<br>
>> -The ``clang::fallthrough`` attribute is used along with the<br>
>> -``-Wimplicit-fallthrough`` argument to annotate intentional fall-through<br>
>> +The ``fallthrough`` (or ``clang::fallthrough``) attribute is used<br>
>> +to annotate intentional fall-through<br>
>> between switch labels. It can only be applied to a null statement placed<br>
>> at a<br>
>> point of execution between any statement and the next switch label. It<br>
>> is<br>
>> common to mark these places with a specific comment, but this attribute<br>
>> is<br>
>> @@ -769,6 +770,10 @@ control-flow statements like ``break;``,<br>
>> where ``break;`` can, but only if there are no statements on the<br>
>> execution path<br>
>> between it and the next switch label.<br>
>><br>
>> +By default, Clang does not warn on unannotated fallthrough from one<br>
>> ``switch``<br>
>> +case to another. Diagnostics on fallthrough without a corresponding<br>
>> annotation<br>
>> +can be enabled with the ``-Wimplicit-fallthrough`` argument.<br>
>> +<br>
>> Here is an example:<br>
>><br>
>> .. code-block:: c++<br>
>><br>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=262881&r1=262880&r2=262881&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=262881&r1=262880&r2=262881&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)<br>
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Mar 7<br>
>> 18:32:55 2016<br>
>> @@ -2358,8 +2358,10 @@ def warn_cxx11_gnu_attribute_on_type : W<br>
>> def warn_unhandled_ms_attribute_ignored : Warning<<br>
>> "__declspec attribute %0 is not supported">,<br>
>> InGroup<IgnoredAttributes>;<br>
>> -def err_attribute_invalid_on_stmt : Error<<br>
>> +def err_decl_attribute_invalid_on_stmt : Error<<br>
>> "%0 attribute cannot be applied to a statement">;<br>
>> +def err_stmt_attribute_invalid_on_decl : Error<<br>
>> + "%0 attribute cannot be applied to a declaration">;<br>
>> def warn_declspec_attribute_ignored : Warning<<br>
>> "attribute %0 is ignored, place it after "<br>
>> "\"%select{class|struct|interface|union|enum}1\" to apply attribute to<br>
>> "<br>
>> @@ -6592,8 +6594,11 @@ def warn_unused_result : Warning<<br>
>> def warn_unused_volatile : Warning<<br>
>> "expression result unused; assign into a variable to force a volatile<br>
>> load">,<br>
>> InGroup<DiagGroup<"unused-volatile-lvalue">>;<br>
>> -def ext_nodiscard_attr_is_a_cxx1z_extension : ExtWarn<<br>
>> - "use of the 'nodiscard' attribute is a C++1z extension">,<br>
>> InGroup<CXX1z>;<br>
>> +<br>
>> +def ext_cxx14_attr : Extension<<br>
>> + "use of the %0 attribute is a C++14 extension">, InGroup<CXX14>;<br>
>> +def ext_cxx1z_attr : Extension<<br>
>> + "use of the %0 attribute is a C++1z extension">, InGroup<CXX1z>;<br>
>><br>
>> def warn_unused_comparison : Warning<<br>
>> "%select{%select{|in}1equality|relational}0 comparison result unused">,<br>
>> @@ -7306,13 +7311,12 @@ def note_insert_fallthrough_fixit : Note<br>
>> def note_insert_break_fixit : Note<<br>
>> "insert 'break;' to avoid fall-through">;<br>
>> def err_fallthrough_attr_wrong_target : Error<<br>
>> - "clang::fallthrough attribute is only allowed on empty statements">;<br>
>> + "%0 attribute is only allowed on empty statements">;<br>
>> def note_fallthrough_insert_semi_fixit : Note<"did you forget ';'?">;<br>
>> def err_fallthrough_attr_outside_switch : Error<<br>
>> "fallthrough annotation is outside switch statement">;<br>
>> -def warn_fallthrough_attr_invalid_placement : Warning<<br>
>> - "fallthrough annotation does not directly precede switch label">,<br>
>> - InGroup<ImplicitFallthrough>;<br>
>> +def err_fallthrough_attr_invalid_placement : Error<<br>
>> + "fallthrough annotation does not directly precede switch label">;<br>
>> def warn_fallthrough_attr_unreachable : Warning<<br>
>> "fallthrough annotation in unreachable code">,<br>
>> InGroup<ImplicitFallthrough>;<br>
>> @@ -7678,9 +7682,6 @@ def err_asm_naked_this_ref : Error<<br>
>> def err_asm_naked_parm_ref : Error<<br>
>> "parameter references not allowed in naked functions">;<br>
>><br>
>> -def ext_deprecated_attr_is_a_cxx14_extension : ExtWarn<<br>
>> - "use of the 'deprecated' attribute is a C++14 extension">,<br>
>> InGroup<CXX14>;<br>
>> -<br>
>> // OpenCL warnings and errors.<br>
>> def err_invalid_astype_of_different_size : Error<<br>
>> "invalid reinterpretation: sizes of %0 and %1 must match">;<br>
>><br>
>> Modified: cfe/trunk/include/clang/Sema/AttributeList.h<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=262881&r1=262880&r2=262881&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=262881&r1=262880&r2=262881&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- cfe/trunk/include/clang/Sema/AttributeList.h (original)<br>
>> +++ cfe/trunk/include/clang/Sema/AttributeList.h Mon Mar 7 18:32:55 2016<br>
>> @@ -491,6 +491,7 @@ public:<br>
>><br>
>> bool isTargetSpecificAttr() const;<br>
>> bool isTypeAttr() const;<br>
>> + bool isStmtAttr() const;<br>
>><br>
>> bool hasCustomParsing() const;<br>
>> unsigned getMinArgs() const;<br>
>><br>
>> Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=262881&r1=262880&r2=262881&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=262881&r1=262880&r2=262881&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)<br>
>> +++ cfe/trunk/include/clang/Sema/ScopeInfo.h Mon Mar 7 18:32:55 2016<br>
>> @@ -107,6 +107,9 @@ public:<br>
>> /// \brief True if current scope is for OpenMP declare reduction<br>
>> combiner.<br>
>> bool HasOMPDeclareReductionCombiner;<br>
>><br>
>> + /// \brief Whether there is a fallthrough statement in this function.<br>
>> + bool HasFallthroughStmt : 1;<br>
>> +<br>
>> /// A flag that is set when parsing a method that must call super's<br>
>> /// implementation, such as \c -dealloc, \c -finalize, or any method<br>
>> marked<br>
>> /// with \c __attribute__((objc_requires_super)).<br>
>> @@ -348,6 +351,10 @@ public:<br>
>> HasOMPDeclareReductionCombiner = true;<br>
>> }<br>
>><br>
>> + void setHasFallthroughStmt() {<br>
>> + HasFallthroughStmt = true;<br>
>> + }<br>
>> +<br>
>> void setHasCXXTry(SourceLocation TryLoc) {<br>
>> setHasBranchProtectedScope();<br>
>> FirstCXXTryLoc = TryLoc;<br>
>> @@ -371,6 +378,7 @@ public:<br>
>> HasIndirectGoto(false),<br>
>> HasDroppedStmt(false),<br>
>> HasOMPDeclareReductionCombiner(false),<br>
>> + HasFallthroughStmt(false),<br>
>> ObjCShouldCallSuper(false),<br>
>> ObjCIsDesignatedInit(false),<br>
>> ObjCWarnForNoDesignatedInitChain(false),<br>
>><br>
>> Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=262881&r1=262880&r2=262881&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=262881&r1=262880&r2=262881&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)<br>
>> +++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Mon Mar 7 18:32:55 2016<br>
>> @@ -1071,6 +1071,34 @@ namespace {<br>
>> };<br>
>> } // anonymous namespace<br>
>><br>
>> +static StringRef getFallthroughAttrSpelling(Preprocessor &PP,<br>
>> + SourceLocation Loc) {<br>
>> + TokenValue FallthroughTokens[] = {<br>
>> + tok::l_square, tok::l_square,<br>
>> + PP.getIdentifierInfo("fallthrough"),<br>
>> + tok::r_square, tok::r_square<br>
>> + };<br>
>> +<br>
>> + TokenValue ClangFallthroughTokens[] = {<br>
>> + tok::l_square, tok::l_square, PP.getIdentifierInfo("clang"),<br>
>> + tok::coloncolon, PP.getIdentifierInfo("fallthrough"),<br>
>> + tok::r_square, tok::r_square<br>
>> + };<br>
>> +<br>
>> + bool PreferClangAttr = !PP.getLangOpts().CPlusPlus1z;<br>
>> +<br>
>> + StringRef MacroName;<br>
>> + if (PreferClangAttr)<br>
>> + MacroName = PP.getLastMacroWithSpelling(Loc, ClangFallthroughTokens);<br>
>> + if (MacroName.empty())<br>
>> + MacroName = PP.getLastMacroWithSpelling(Loc, FallthroughTokens);<br>
>> + if (MacroName.empty() && !PreferClangAttr)<br>
>> + MacroName = PP.getLastMacroWithSpelling(Loc, ClangFallthroughTokens);<br>
>> + if (MacroName.empty())<br>
>> + MacroName = PreferClangAttr ? "[[clang::fallthrough]]" :<br>
>> "[[fallthrough]]";<br>
>> + return MacroName;<br>
>> +}<br>
>> +<br>
>> static void DiagnoseSwitchLabelsFallthrough(Sema &S, AnalysisDeclContext<br>
>> &AC,<br>
>> bool PerFunction) {<br>
>> // Only perform this analysis when using C++11. There is no good<br>
>> workflow<br>
>> @@ -1129,15 +1157,7 @@ static void DiagnoseSwitchLabelsFallthro<br>
>> }<br>
>> if (!(B->empty() && Term && isa<BreakStmt>(Term))) {<br>
>> Preprocessor &PP = S.getPreprocessor();<br>
>> - TokenValue Tokens[] = {<br>
>> - tok::l_square, tok::l_square, PP.getIdentifierInfo("clang"),<br>
>> - tok::coloncolon, PP.getIdentifierInfo("fallthrough"),<br>
>> - tok::r_square, tok::r_square<br>
>> - };<br>
>> - StringRef AnnotationSpelling = "[[clang::fallthrough]]";<br>
>> - StringRef MacroName = PP.getLastMacroWithSpelling(L, Tokens);<br>
>> - if (!MacroName.empty())<br>
>> - AnnotationSpelling = MacroName;<br>
>> + StringRef AnnotationSpelling = getFallthroughAttrSpelling(PP,<br>
>> L);<br>
>> SmallString<64> TextToInsert(AnnotationSpelling);<br>
>> TextToInsert += "; ";<br>
>> S.Diag(L, diag::note_insert_fallthrough_fixit) <<<br>
>> @@ -1151,7 +1171,7 @@ static void DiagnoseSwitchLabelsFallthro<br>
>> }<br>
>><br>
>> for (const auto *F : FM.getFallthroughStmts())<br>
>> - S.Diag(F->getLocStart(),<br>
>> diag::warn_fallthrough_attr_invalid_placement);<br>
>> + S.Diag(F->getLocStart(),<br>
>> diag::err_fallthrough_attr_invalid_placement);<br>
>> }<br>
>><br>
>> static bool isInLoop(const ASTContext &Ctx, const ParentMap &PM,<br>
>> @@ -2038,7 +2058,8 @@ AnalysisBasedWarnings::IssueWarnings(sem<br>
>> !Diags.isIgnored(diag::warn_unannotated_fallthrough,<br>
>> D->getLocStart());<br>
>> bool FallThroughDiagPerFunction = !Diags.isIgnored(<br>
>> diag::warn_unannotated_fallthrough_per_function, D->getLocStart());<br>
>> - if (FallThroughDiagFull || FallThroughDiagPerFunction) {<br>
>> + if (FallThroughDiagFull || FallThroughDiagPerFunction ||<br>
>> + fscope->HasFallthroughStmt) {<br>
>> DiagnoseSwitchLabelsFallthrough(S, AC, !FallThroughDiagFull);<br>
>> }<br>
>><br>
>><br>
>> Modified: cfe/trunk/lib/Sema/AttributeList.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AttributeList.cpp?rev=262881&r1=262880&r2=262881&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AttributeList.cpp?rev=262881&r1=262880&r2=262881&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- cfe/trunk/lib/Sema/AttributeList.cpp (original)<br>
>> +++ cfe/trunk/lib/Sema/AttributeList.cpp Mon Mar 7 18:32:55 2016<br>
>> @@ -159,6 +159,7 @@ struct ParsedAttrInfo {<br>
>> unsigned HasCustomParsing : 1;<br>
>> unsigned IsTargetSpecific : 1;<br>
>> unsigned IsType : 1;<br>
>> + unsigned IsStmt : 1;<br>
>> unsigned IsKnownToGCC : 1;<br>
>><br>
>> bool (*DiagAppertainsToDecl)(Sema &S, const AttributeList &Attr,<br>
>> @@ -204,6 +205,10 @@ bool AttributeList::isTypeAttr() const {<br>
>> return getInfo(*this).IsType;<br>
>> }<br>
>><br>
>> +bool AttributeList::isStmtAttr() const {<br>
>> + return getInfo(*this).IsStmt;<br>
>> +}<br>
>> +<br>
>> bool AttributeList::existsInTarget(const TargetInfo &Target) const {<br>
>> return getInfo(*this).ExistsInTarget(Target);<br>
>> }<br>
>><br>
>> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=262881&r1=262880&r2=262881&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=262881&r1=262880&r2=262881&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)<br>
>> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Mon Mar 7 18:32:55 2016<br>
>> @@ -2467,7 +2467,7 @@ static void handleWarnUnusedResult(Sema<br>
>> // about using it as an extension.<br>
>> if (!S.getLangOpts().CPlusPlus1z && Attr.isCXX11Attribute() &&<br>
>> !Attr.getScopeName())<br>
>> - S.Diag(Attr.getLoc(), diag::ext_nodiscard_attr_is_a_cxx1z_extension);<br>
>> + S.Diag(Attr.getLoc(), diag::ext_cxx1z_attr) << Attr.getName();<br>
>><br>
>> D->addAttr(::new (S.Context)<br>
>> WarnUnusedResultAttr(Attr.getRange(), S.Context,<br>
>> @@ -5072,7 +5072,7 @@ static void handleDeprecatedAttr(Sema &S<br>
>> if (!S.getLangOpts().CPlusPlus14)<br>
>> if (Attr.isCXX11Attribute() &&<br>
>> !(Attr.hasScope() && Attr.getScopeName()->isStr("gnu")))<br>
>> - S.Diag(Attr.getLoc(),<br>
>> diag::ext_deprecated_attr_is_a_cxx14_extension);<br>
>> + S.Diag(Attr.getLoc(), diag::ext_cxx14_attr) << Attr.getName();<br>
>><br>
>> handleAttrWithMessage<DeprecatedAttr>(S, D, Attr);<br>
>> }<br>
>> @@ -5234,8 +5234,13 @@ static void ProcessDeclAttribute(Sema &S<br>
>><br>
>> switch (Attr.getKind()) {<br>
>> default:<br>
>> - // Type attributes are handled elsewhere; silently move on.<br>
>> - assert(Attr.isTypeAttr() && "Non-type attribute not handled");<br>
>> + if (!Attr.isStmtAttr()) {<br>
>> + // Type attributes are handled elsewhere; silently move on.<br>
>> + assert(Attr.isTypeAttr() && "Non-type attribute not handled");<br>
>> + break;<br>
>> + }<br>
>> + S.Diag(Attr.getLoc(), diag::err_stmt_attribute_invalid_on_decl)<br>
>> + << Attr.getName() << D->getLocation();<br>
>> break;<br>
>> case AttributeList::AT_Interrupt:<br>
>> handleInterruptAttr(S, D, Attr);<br>
>><br>
>> Modified: cfe/trunk/lib/Sema/SemaStmtAttr.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAttr.cpp?rev=262881&r1=262880&r2=262881&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAttr.cpp?rev=262881&r1=262880&r2=262881&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- cfe/trunk/lib/Sema/SemaStmtAttr.cpp (original)<br>
>> +++ cfe/trunk/lib/Sema/SemaStmtAttr.cpp Mon Mar 7 18:32:55 2016<br>
>> @@ -25,9 +25,11 @@ using namespace sema;<br>
>><br>
>> static Attr *handleFallThroughAttr(Sema &S, Stmt *St, const AttributeList<br>
>> &A,<br>
>> SourceRange Range) {<br>
>> + FallThroughAttr Attr(A.getRange(), S.Context,<br>
>> + A.getAttributeSpellingListIndex());<br>
>> if (!isa<NullStmt>(St)) {<br>
>> S.Diag(A.getRange().getBegin(),<br>
>> diag::err_fallthrough_attr_wrong_target)<br>
>> - << St->getLocStart();<br>
>> + << Attr.getSpelling() << St->getLocStart();<br>
>> if (isa<SwitchCase>(St)) {<br>
>> SourceLocation L = S.getLocForEndOfToken(Range.getEnd());<br>
>> S.Diag(L, diag::note_fallthrough_insert_semi_fixit)<br>
>> @@ -35,12 +37,20 @@ static Attr *handleFallThroughAttr(Sema<br>
>> }<br>
>> return nullptr;<br>
>> }<br>
>> - if (S.getCurFunction()->SwitchStack.empty()) {<br>
>> + auto *FnScope = S.getCurFunction();<br>
>> + if (FnScope->SwitchStack.empty()) {<br>
>> S.Diag(A.getRange().getBegin(),<br>
>> diag::err_fallthrough_attr_outside_switch);<br>
>> return nullptr;<br>
>> }<br>
>> - return ::new (S.Context) FallThroughAttr(A.getRange(), S.Context,<br>
>> -<br>
>> A.getAttributeSpellingListIndex());<br>
>> +<br>
>> + // If this is spelled as the standard C++1z attribute, but not in<br>
>> C++1z, warn<br>
>> + // about using it as an extension.<br>
>> + if (!S.getLangOpts().CPlusPlus1z && A.isCXX11Attribute() &&<br>
>> + !A.getScopeName())<br>
>> + S.Diag(A.getLoc(), diag::ext_cxx1z_attr) << A.getName();<br>
>> +<br>
>> + FnScope->setHasFallthroughStmt();<br>
>> + return ::new (S.Context) auto(Attr);<br>
>> }<br>
>><br>
>> static Attr *handleLoopHintAttr(Sema &S, Stmt *St, const AttributeList<br>
>> &A,<br>
>> @@ -266,7 +276,7 @@ static Attr *ProcessStmtAttribute(Sema &<br>
>> default:<br>
>> // if we're here, then we parsed a known attribute, but didn't<br>
>> recognize<br>
>> // it as a statement attribute => it is declaration attribute<br>
>> - S.Diag(A.getRange().getBegin(), diag::err_attribute_invalid_on_stmt)<br>
>> + S.Diag(A.getRange().getBegin(),<br>
>> diag::err_decl_attribute_invalid_on_stmt)<br>
>> << A.getName() << St->getLocStart();<br>
>> return nullptr;<br>
>> }<br>
>><br>
>> Modified: cfe/trunk/test/Analysis/cxx11-crashes.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cxx11-crashes.cpp?rev=262881&r1=262880&r2=262881&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cxx11-crashes.cpp?rev=262881&r1=262880&r2=262881&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- cfe/trunk/test/Analysis/cxx11-crashes.cpp (original)<br>
>> +++ cfe/trunk/test/Analysis/cxx11-crashes.cpp Mon Mar 7 18:32:55 2016<br>
>> @@ -1,5 +1,4 @@<br>
>> // RUN: %clang_cc1 -analyze -analyzer-checker=core -std=c++11 -verify %s<br>
>> -// expected-no-diagnostics<br>
>><br>
>> // radar://11485149, PR12871<br>
>> class PlotPoint {<br>
>> @@ -91,6 +90,6 @@ void test() {<br>
>> void fallthrough() {<br>
>> switch (1) {<br>
>> case 1:<br>
>> - [[clang::fallthrough]];<br>
>> + [[clang::fallthrough]]; // expected-error {{does not directly<br>
>> precede}}<br>
>> }<br>
>> }<br>
>><br>
>> Modified: cfe/trunk/test/PCH/Inputs/cxx11-statement-attributes.h<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/Inputs/cxx11-statement-attributes.h?rev=262881&r1=262880&r2=262881&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/Inputs/cxx11-statement-attributes.h?rev=262881&r1=262880&r2=262881&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- cfe/trunk/test/PCH/Inputs/cxx11-statement-attributes.h (original)<br>
>> +++ cfe/trunk/test/PCH/Inputs/cxx11-statement-attributes.h Mon Mar 7<br>
>> 18:32:55 2016<br>
>> @@ -7,7 +7,8 @@ int f(int n) {<br>
>> [[clang::fallthrough]]; // This shouldn't generate a warning.<br>
>> case 1:<br>
>> n += 20;<br>
>> - [[clang::fallthrough]]; // This should generate a warning:<br>
>> "fallthrough annotation does not directly precede switch label".<br>
>> + case 2: // This should generate a warning: "unannotated fallthrough"<br>
>> + n += 35;<br>
>> break;<br>
>> }<br>
>> return n;<br>
>><br>
>> Modified: cfe/trunk/test/PCH/cxx11-statement-attributes.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx11-statement-attributes.cpp?rev=262881&r1=262880&r2=262881&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx11-statement-attributes.cpp?rev=262881&r1=262880&r2=262881&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- cfe/trunk/test/PCH/cxx11-statement-attributes.cpp (original)<br>
>> +++ cfe/trunk/test/PCH/cxx11-statement-attributes.cpp Mon Mar 7 18:32:55<br>
>> 2016<br>
>> @@ -1,10 +1,15 @@<br>
>> // Sanity check.<br>
>> // RUN: %clang_cc1 -include %S/Inputs/cxx11-statement-attributes.h<br>
>> -std=c++11 -Wimplicit-fallthrough -fsyntax-only %s -o - -verify<br>
>> +// RUN: %clang_cc1 -include %S/Inputs/cxx11-statement-attributes.h<br>
>> -std=c++1z -Wimplicit-fallthrough -fsyntax-only %s -o - -verify<br>
>> // Run the same tests, this time with the attributes loaded from the PCH<br>
>> file.<br>
>> // RUN: %clang_cc1 -x c++-header -emit-pch -std=c++11 -o %t<br>
>> %S/Inputs/cxx11-statement-attributes.h<br>
>> // RUN: %clang_cc1 -include-pch %t -std=c++11 -Wimplicit-fallthrough<br>
>> -fsyntax-only %s -o - -verify<br>
>> +// RUN: %clang_cc1 -x c++-header -emit-pch -std=c++1z -o %t<br>
>> %S/Inputs/cxx11-statement-attributes.h<br>
>> +// RUN: %clang_cc1 -include-pch %t -std=c++1z -Wimplicit-fallthrough<br>
>> -fsyntax-only %s -o - -verify<br>
>><br>
>> -// expected-warning@Inputs/cxx11-statement-attributes.h:10 {{fallthrough<br>
>> annotation does not directly precede switch label}}<br>
>> +// expected-warning@Inputs/cxx11-statement-attributes.h:10 {{unannotated<br>
>> fall-through}}<br>
>> +// expected-note-re@Inputs/cxx11-statement-attributes.h:10 {{insert<br>
>> '[[{{(clang::)?}}fallthrough]];'}}<br>
>> +// expected-note@Inputs/cxx11-statement-attributes.h:10 {{insert<br>
>> 'break;'}}<br>
>><br>
>> void g(int n) {<br>
>> f<1>(n); // expected-note {{in instantiation of function template<br>
>> specialization 'f<1>' requested here}}<br>
>><br>
>> Modified: cfe/trunk/test/Parser/cxx0x-attributes.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx0x-attributes.cpp?rev=262881&r1=262880&r2=262881&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx0x-attributes.cpp?rev=262881&r1=262880&r2=262881&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- cfe/trunk/test/Parser/cxx0x-attributes.cpp (original)<br>
>> +++ cfe/trunk/test/Parser/cxx0x-attributes.cpp Mon Mar 7 18:32:55 2016<br>
>> @@ -1,4 +1,4 @@<br>
>> -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify<br>
>> -std=c++11 -Wc++14-compat %s<br>
>> +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify<br>
>> -std=c++11 -Wc++14-compat -Wc++14-extensions -Wc++1z-extensions %s<br>
>><br>
>> // Need std::initializer_list<br>
>> namespace std {<br>
>> @@ -347,6 +347,18 @@ deprecated<br>
>> ]] void bad();<br>
>> }<br>
>><br>
>> +int fallthru(int n) {<br>
>> + switch (n) {<br>
>> + case 0:<br>
>> + n += 5;<br>
>> + [[fallthrough]]; // expected-warning {{use of the 'fallthrough'<br>
>> attribute is a C++1z extension}}<br>
>> + case 1:<br>
>> + n *= 2;<br>
>> + break;<br>
>> + }<br>
>> + return n;<br>
>> +}<br>
>> +<br>
>> #define attr_name bitand<br>
>> #define attr_name_2(x) x<br>
>> #define attr_name_3(x, y) x##y<br>
>><br>
>> Modified: cfe/trunk/test/SemaCXX/for-range-examples.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/for-range-examples.cpp?rev=262881&r1=262880&r2=262881&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/for-range-examples.cpp?rev=262881&r1=262880&r2=262881&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- cfe/trunk/test/SemaCXX/for-range-examples.cpp (original)<br>
>> +++ cfe/trunk/test/SemaCXX/for-range-examples.cpp Mon Mar 7 18:32:55 2016<br>
>> @@ -226,7 +226,7 @@ namespace test7 {<br>
>> // we check the alignment attribute before we perform the auto<br>
>> // deduction.<br>
>> for (d alignas(1) : arr) {} // expected-error {{requires type for<br>
>> loop variable}}<br>
>> - for (e [[deprecated]] : arr) { e = 0; } // expected-warning{{use of<br>
>> the 'deprecated' attribute is a C++14 extension}} expected-warning<br>
>> {{deprecated}} expected-note {{here}} expected-error {{requires type for<br>
>> loop variable}}<br>
>> + for (e [[deprecated]] : arr) { e = 0; } // expected-warning<br>
>> {{deprecated}} expected-note {{here}} expected-error {{requires type for<br>
>> loop variable}}<br>
>> }<br>
>> }<br>
>><br>
>><br>
>> Modified: cfe/trunk/test/SemaCXX/generalized-deprecated.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/generalized-deprecated.cpp?rev=262881&r1=262880&r2=262881&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/generalized-deprecated.cpp?rev=262881&r1=262880&r2=262881&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- cfe/trunk/test/SemaCXX/generalized-deprecated.cpp (original)<br>
>> +++ cfe/trunk/test/SemaCXX/generalized-deprecated.cpp Mon Mar 7 18:32:55<br>
>> 2016<br>
>> @@ -1,4 +1,4 @@<br>
>> -// RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only -fms-extensions<br>
>> -Wno-deprecated %s<br>
>> +// RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only -fms-extensions<br>
>> -Wno-deprecated -Wc++14-extensions %s<br>
>><br>
>> // NOTE: use -Wno-deprecated to avoid cluttering the output with<br>
>> deprecated<br>
>> // warnings<br>
>><br>
>> Modified: cfe/trunk/test/SemaCXX/nodiscard.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/nodiscard.cpp?rev=262881&r1=262880&r2=262881&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/nodiscard.cpp?rev=262881&r1=262880&r2=262881&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- cfe/trunk/test/SemaCXX/nodiscard.cpp (original)<br>
>> +++ cfe/trunk/test/SemaCXX/nodiscard.cpp Mon Mar 7 18:32:55 2016<br>
>> @@ -1,5 +1,5 @@<br>
>> -// RUN: %clang_cc1 -fsyntax-only -std=c++1z -verify %s<br>
>> -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify -DEXT %s<br>
>> +// RUN: %clang_cc1 -fsyntax-only -std=c++1z -verify -Wc++1z-extensions %s<br>
>> +// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify -DEXT<br>
>> -Wc++1z-extensions %s<br>
>><br>
>> #if !defined(EXT)<br>
>> static_assert(__has_cpp_attribute(nodiscard) == 201603);<br>
>><br>
>> Modified: cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-macro.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-macro.cpp?rev=262881&r1=262880&r2=262881&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-macro.cpp?rev=262881&r1=262880&r2=262881&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-macro.cpp<br>
>> (original)<br>
>> +++ cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-macro.cpp Mon Mar<br>
>> 7 18:32:55 2016<br>
>> @@ -1,4 +1,8 @@<br>
>> -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11<br>
>> -Wimplicit-fallthrough -DCOMMAND_LINE_FALLTHROUGH=[[clang::fallthrough]] %s<br>
>> +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11<br>
>> -Wimplicit-fallthrough -DCLANG_PREFIX<br>
>> -DCOMMAND_LINE_FALLTHROUGH=[[clang::fallthrough]] -DUNCHOSEN=[[fallthrough]]<br>
>> %s<br>
>> +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11<br>
>> -Wimplicit-fallthrough -DCOMMAND_LINE_FALLTHROUGH=[[fallthrough]] %s<br>
>> +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z<br>
>> -Wimplicit-fallthrough -DCLANG_PREFIX<br>
>> -DCOMMAND_LINE_FALLTHROUGH=[[clang::fallthrough]] %s<br>
>> +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z<br>
>> -Wimplicit-fallthrough -DCOMMAND_LINE_FALLTHROUGH=[[clang::fallthrough]] %s<br>
>> +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z<br>
>> -Wimplicit-fallthrough -DCOMMAND_LINE_FALLTHROUGH=[[fallthrough]]<br>
>> -DUNCHOSEN=[[clang::fallthrough]] %s<br>
>><br>
>> int fallthrough_compatibility_macro_from_command_line(int n) {<br>
>> switch (n) {<br>
>> @@ -10,15 +14,12 @@ int fallthrough_compatibility_macro_from<br>
>> return n;<br>
>> }<br>
>><br>
>> -#ifdef __clang__<br>
>> -#if __has_feature(cxx_attributes) &&<br>
>> __has_warning("-Wimplicit-fallthrough")<br>
>> +#ifdef CLANG_PREFIX<br>
>> #define COMPATIBILITY_FALLTHROUGH [ [ /* test */ clang /* test */ \<br>
>> :: fallthrough ] ] // testing whitespace and comments in macro<br>
>> definition<br>
>> -#endif<br>
>> -#endif<br>
>> -<br>
>> -#ifndef COMPATIBILITY_FALLTHROUGH<br>
>> -#define COMPATIBILITY_FALLTHROUGH do { } while (0)<br>
>> +#else<br>
>> +#define COMPATIBILITY_FALLTHROUGH [ [ /* test */ /* test */ \<br>
>> + fallthrough ] ] // testing whitespace and comments in macro<br>
>> definition<br>
>> #endif<br>
>><br>
>> int fallthrough_compatibility_macro_from_source(int n) {<br>
>> @@ -32,7 +33,11 @@ int fallthrough_compatibility_macro_from<br>
>> }<br>
>><br>
>> // Deeper macro substitution<br>
>> +#ifdef CLANG_PREFIX<br>
>> #define M1 [[clang::fallthrough]]<br>
>> +#else<br>
>> +#define M1 [[fallthrough]]<br>
>> +#endif<br>
>> #ifdef __clang__<br>
>> #define M2 M1<br>
>> #else<br>
>> @@ -59,12 +64,17 @@ int fallthrough_compatibility_macro_in_m<br>
>> #undef M2<br>
>> #undef COMPATIBILITY_FALLTHROUGH<br>
>> #undef COMMAND_LINE_FALLTHROUGH<br>
>> +#undef UNCHOSEN<br>
>><br>
>> int fallthrough_compatibility_macro_undefined(int n) {<br>
>> switch (n) {<br>
>> case 0:<br>
>> n = n * 20;<br>
>> +#if __cplusplus <= 201402L<br>
>> case 1: // expected-warning{{unannotated fall-through between switch<br>
>> labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this<br>
>> warning}} expected-note{{insert 'break;' to avoid fall-through}}<br>
>> +#else<br>
>> + case 1: // expected-warning{{unannotated fall-through between switch<br>
>> labels}} expected-note{{insert '[[fallthrough]];' to silence this warning}}<br>
>> expected-note{{insert 'break;' to avoid fall-through}}<br>
>> +#endif<br>
>> ;<br>
>> }<br>
>> #define TOO_LATE [[clang::fallthrough]]<br>
>> @@ -83,7 +93,11 @@ int fallthrough_compatibility_macro_hist<br>
>> case 0:<br>
>> n = n * 20;<br>
>> #undef MACRO_WITH_HISTORY<br>
>> +#if __cplusplus <= 201402L<br>
>> case 1: // expected-warning{{unannotated fall-through between switch<br>
>> labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this<br>
>> warning}} expected-note{{insert 'break;' to avoid fall-through}}<br>
>> +#else<br>
>> + case 1: // expected-warning{{unannotated fall-through between switch<br>
>> labels}} expected-note{{insert '[[fallthrough]];' to silence this warning}}<br>
>> expected-note{{insert 'break;' to avoid fall-through}}<br>
>> +#endif<br>
>> ;<br>
>> #define MACRO_WITH_HISTORY [[clang::fallthrough]]<br>
>> }<br>
>><br>
>> Modified:<br>
>> cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-per-method.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-per-method.cpp?rev=262881&r1=262880&r2=262881&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-per-method.cpp?rev=262881&r1=262880&r2=262881&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-per-method.cpp<br>
>> (original)<br>
>> +++ cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-per-method.cpp Mon<br>
>> Mar 7 18:32:55 2016<br>
>> @@ -41,9 +41,8 @@ int fallthrough2(int n) {<br>
>> void unscoped(int n) {<br>
>> switch (n % 2) {<br>
>> case 0:<br>
>> - // FIXME: This should be typo-corrected, probably.<br>
>> - [[fallthrough]]; // expected-warning{{unknown attribute<br>
>> 'fallthrough' ignored}}<br>
>> - case 2: // expected-warning{{unannotated fall-through}}<br>
>> expected-note{{clang::fallthrough}} expected-note{{break;}}<br>
>> + [[fallthrough]];<br>
>> + case 2:<br>
>> [[clang::fallthrough]];<br>
>> case 1:<br>
>> break;<br>
>><br>
>> Modified: cfe/trunk/test/SemaCXX/switch-implicit-fallthrough.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/switch-implicit-fallthrough.cpp?rev=262881&r1=262880&r2=262881&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/switch-implicit-fallthrough.cpp?rev=262881&r1=262880&r2=262881&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- cfe/trunk/test/SemaCXX/switch-implicit-fallthrough.cpp (original)<br>
>> +++ cfe/trunk/test/SemaCXX/switch-implicit-fallthrough.cpp Mon Mar 7<br>
>> 18:32:55 2016<br>
>> @@ -179,18 +179,15 @@ void fallthrough_cfgblock_with_null_succ<br>
>><br>
>> int fallthrough_position(int n) {<br>
>> switch (n) {<br>
>> - [[clang::fallthrough]]; // expected-warning{{fallthrough<br>
>> annotation does not directly precede switch label}}<br>
>> n += 300;<br>
>> [[clang::fallthrough]]; // expected-warning{{fallthrough<br>
>> annotation in unreachable code}}<br>
>> case 221:<br>
>> - [[clang::fallthrough]]; // expected-warning{{fallthrough<br>
>> annotation does not directly precede switch label}}<br>
>> return 1;<br>
>> [[clang::fallthrough]]; // expected-warning{{fallthrough<br>
>> annotation in unreachable code}}<br>
>> case 222:<br>
>> - [[clang::fallthrough]]; // expected-warning{{fallthrough<br>
>> annotation does not directly precede switch label}}<br>
>> n += 400;<br>
>> case 223: // expected-warning{{unannotated fall-through<br>
>> between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to<br>
>> silence this warning}} expected-note{{insert 'break;' to avoid<br>
>> fall-through}}<br>
>> - [[clang::fallthrough]]; // expected-warning{{fallthrough annotation<br>
>> does not directly precede switch label}}<br>
>> + ;<br>
>> }<br>
>><br>
>> long p = static_cast<long>(n) * n;<br>
>> @@ -282,6 +279,23 @@ namespace PR18983 {<br>
>> }<br>
>> }<br>
>><br>
>> +int fallthrough_placement_error(int n) {<br>
>> + switch (n) {<br>
>> + [[clang::fallthrough]]; // expected-warning{{fallthrough annotation<br>
>> in unreachable code}}<br>
>> + n += 300;<br>
>> + case 221:<br>
>> + [[clang::fallthrough]]; // expected-error{{fallthrough annotation<br>
>> does not directly precede switch label}}<br>
>> + return 1;<br>
>> + case 222:<br>
>> + [[clang::fallthrough]]; // expected-error{{fallthrough annotation<br>
>> does not directly precede switch label}}<br>
>> + n += 400;<br>
>> + [[clang::fallthrough]];<br>
>> + case 223:<br>
>> + [[clang::fallthrough]]; // expected-error{{fallthrough annotation<br>
>> does not directly precede switch label}}<br>
>> + }<br>
>> + return n;<br>
>> +}<br>
>> +<br>
>> int fallthrough_targets(int n) {<br>
>> [[clang::fallthrough]]; // expected-error{{fallthrough annotation is<br>
>> outside switch statement}}<br>
>><br>
>><br>
>> Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=262881&r1=262880&r2=262881&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=262881&r1=262880&r2=262881&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)<br>
>> +++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Mon Mar 7 18:32:55 2016<br>
>> @@ -1761,6 +1761,7 @@ namespace {<br>
>><br>
>> static const AttrClassDescriptor AttrClassDescriptors[] = {<br>
>> { "ATTR", "Attr" },<br>
>> + { "STMT_ATTR", "StmtAttr" },<br>
>> { "INHERITABLE_ATTR", "InheritableAttr" },<br>
>> { "INHERITABLE_PARAM_ATTR", "InheritableParamAttr" },<br>
>> { "PARAMETER_ABI_ATTR", "ParameterABIAttr" }<br>
>> @@ -2806,6 +2807,7 @@ void EmitClangAttrParsedAttrImpl(RecordK<br>
>> SS << ", " << I->second->getValueAsBit("HasCustomParsing");<br>
>> SS << ", " << I->second->isSubClassOf("TargetSpecificAttr");<br>
>> SS << ", " << I->second->isSubClassOf("TypeAttr");<br>
>> + SS << ", " << I->second->isSubClassOf("StmtAttr");<br>
>> SS << ", " << IsKnownToGCC(*I->second);<br>
>> SS << ", " << GenerateAppertainsTo(*I->second, OS);<br>
>> SS << ", " << GenerateLangOptRequirements(*I->second, OS);<br>
>><br>
>> Modified: cfe/trunk/www/cxx_status.html<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=262881&r1=262880&r2=262881&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=262881&r1=262880&r2=262881&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- cfe/trunk/www/cxx_status.html (original)<br>
>> +++ cfe/trunk/www/cxx_status.html Mon Mar 7 18:32:55 2016<br>
>> @@ -629,7 +629,7 @@ as the draft C++1z standard evolves.</p><br>
>> <tr><br>
>> <td><tt>[[fallthrough]]</tt> attribute</td><br>
>> <td><a href="<a href="http://wg21.link/p0188r1" rel="noreferrer" target="_blank">http://wg21.link/p0188r1</a>">P0188R1</a></td><br>
>> - <td class="none" align="center">No</td><br>
>> + <td class="full" align="center">SVN</td><br>
>> </tr><br>
>> <tr><br>
>> <td><tt>[[nodiscard]]</tt> attribute</td><br>
>><br>
>><br>
>> _______________________________________________<br>
>> cfe-commits mailing list<br>
>> <a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
><br>
><br>
</div></div></blockquote></div><br></div></div>