diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 8 | ||||
-rw-r--r-- | include/clang/Sema/DeclSpec.h | 38 | ||||
-rw-r--r-- | include/clang/Sema/Scope.h | 49 |
3 files changed, 73 insertions, 22 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 31a847b129..e092b9a772 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -5898,6 +5898,14 @@ def err_noreturn_missing_on_first_decl : Error< "function declared '[[noreturn]]' after its first declaration">; def note_noreturn_missing_first_decl : Note< "declaration missing '[[noreturn]]' attribute is here">; +def err_carries_dependency_missing_on_first_decl : Error< + "%select{function|parameter}0 declared '[[carries_dependency]]' " + "after its first declaration">; +def note_carries_dependency_missing_first_decl : Note< + "declaration missing '[[carries_dependency]]' attribute is here">; +def err_carries_dependency_param_not_function_decl : Error< + "'[[carries_dependency]]' attribute only allowed on parameter in a function " + "declaration or lambda">; def err_block_on_nonlocal : Error< "__block attribute not allowed, only allowed on local variables">; def err_block_on_vm : Error< diff --git a/include/clang/Sema/DeclSpec.h b/include/clang/Sema/DeclSpec.h index 0d2c948399..fc43ed66fb 100644 --- a/include/clang/Sema/DeclSpec.h +++ b/include/clang/Sema/DeclSpec.h @@ -1879,6 +1879,44 @@ public: /// type. This routine checks for both cases. bool isDeclarationOfFunction() const; + /// \brief Return true if a function declarator at this position would be a + /// function declaration. + bool isFunctionDeclaratorAFunctionDeclaration() const { + if (getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef) + return false; + + for (unsigned I = 0, N = getNumTypeObjects(); I != N; ++I) + if (getTypeObject(I).Kind != DeclaratorChunk::Paren) + return false; + + switch (Context) { + case FileContext: + case MemberContext: + case BlockContext: + return true; + + case ForContext: + case ConditionContext: + case KNRTypeListContext: + case TypeNameContext: + case AliasDeclContext: + case AliasTemplateContext: + case PrototypeContext: + case ObjCParameterContext: + case ObjCResultContext: + case TemplateParamContext: + case CXXNewContext: + case CXXCatchContext: + case ObjCCatchContext: + case BlockLiteralContext: + case LambdaExprContext: + case TemplateTypeArgContext: + case TrailingReturnContext: + return false; + } + llvm_unreachable("unknown context kind!"); + } + /// takeAttributes - Takes attributes from the given parsed-attributes /// set and add them to this declarator. /// diff --git a/include/clang/Sema/Scope.h b/include/clang/Sema/Scope.h index 855485d08e..4957d85e00 100644 --- a/include/clang/Sema/Scope.h +++ b/include/clang/Sema/Scope.h @@ -32,61 +32,66 @@ public: /// ScopeFlags - These are bitfields that are or'd together when creating a /// scope, which defines the sorts of things the scope contains. enum ScopeFlags { - /// FnScope - This indicates that the scope corresponds to a function, which + /// \brief This indicates that the scope corresponds to a function, which /// means that labels are set here. FnScope = 0x01, - /// BreakScope - This is a while,do,switch,for, etc that can have break - /// stmts embedded into it. + /// \brief This is a while, do, switch, for, etc that can have break + /// statements embedded into it. BreakScope = 0x02, - /// ContinueScope - This is a while,do,for, which can have continue - /// stmt embedded into it. + /// \brief This is a while, do, for, which can have continue statements + /// embedded into it. ContinueScope = 0x04, - /// DeclScope - This is a scope that can contain a declaration. Some scopes + /// \brief This is a scope that can contain a declaration. Some scopes /// just contain loop constructs but don't contain decls. DeclScope = 0x08, - /// ControlScope - The controlling scope in a if/switch/while/for statement. + /// \brief The controlling scope in a if/switch/while/for statement. ControlScope = 0x10, - /// ClassScope - The scope of a struct/union/class definition. + /// \brief The scope of a struct/union/class definition. ClassScope = 0x20, - /// BlockScope - This is a scope that corresponds to a block/closure object. + /// \brief This is a scope that corresponds to a block/closure object. /// Blocks serve as top-level scopes for some objects like labels, they /// also prevent things like break and continue. BlockScopes always have /// the FnScope and DeclScope flags set as well. BlockScope = 0x40, - /// TemplateParamScope - This is a scope that corresponds to the + /// \brief This is a scope that corresponds to the /// template parameters of a C++ template. Template parameter /// scope starts at the 'template' keyword and ends when the /// template declaration ends. TemplateParamScope = 0x80, - /// FunctionPrototypeScope - This is a scope that corresponds to the + /// \brief This is a scope that corresponds to the /// parameters within a function prototype. FunctionPrototypeScope = 0x100, - /// AtCatchScope - This is a scope that corresponds to the Objective-C + /// \brief This is a scope that corresponds to the parameters within + /// a function prototype for a function declaration (as opposed to any + /// other kind of function declarator). Always has FunctionPrototypeScope + /// set as well. + FunctionDeclarationScope = 0x200, + + /// \brief This is a scope that corresponds to the Objective-C /// \@catch statement. - AtCatchScope = 0x200, + AtCatchScope = 0x400, - /// ObjCMethodScope - This scope corresponds to an Objective-C method body. + /// \brief This scope corresponds to an Objective-C method body. /// It always has FnScope and DeclScope set as well. - ObjCMethodScope = 0x400, + ObjCMethodScope = 0x800, - /// SwitchScope - This is a scope that corresponds to a switch statement. - SwitchScope = 0x800, + /// \brief This is a scope that corresponds to a switch statement. + SwitchScope = 0x1000, - /// TryScope - This is the scope of a C++ try statement. - TryScope = 0x1000, + /// \brief This is the scope of a C++ try statement. + TryScope = 0x2000, - /// FnTryCatchScope - This is the scope for a function-level C++ try or - /// catch scope. - FnTryCatchScope = 0x2000 + /// \brief This is the scope for a function-level C++ try or catch scope. + FnTryCatchScope = 0x4000 }; private: /// The parent scope for this scope. This is null for the translation-unit |