Lines Matching +defs:symbol +defs:function
25 #include "flang/Semantics/symbol.h"
214 const Symbol &symbol{specific.GetUltimate()};
215 if (semantics::IsProcedure(symbol)) {
216 if (symbol.attrs().test(semantics::Attr::ABSTRACT)) {
227 } else if (!symbol.attrs().test(semantics::Attr::INTRINSIC)) {
228 if (symbol.has<semantics::GenericDetails>()) {
235 return Expr<SomeType>{ProcedureDesignator{symbol}};
238 symbol.name().ToString())};
241 symbol.name().ToString(), std::move(*interface)};
252 context_, GetContextualMessages().at(), &symbol)) {
255 if (!context_.HasError(last) && !context_.HasError(symbol)) {
259 symbol);
269 const Symbol &symbol{ref.GetLastSymbol().GetUltimate()};
270 int symbolRank{symbol.Rank()};
277 symbolRank, symbol.name(), subscripts);
280 } else if (symbol.has<semantics::ObjectEntityDetails>() ||
281 symbol.has<semantics::AssocEntityDetails>()) {
284 if (!last->upper() && IsAssumedSizeArray(symbol)) {
287 symbol.name());
295 CHECK(symbol.has<semantics::AssocEntityDetails>());
297 if (!semantics::IsNamedConstant(symbol) && !inDataStmtObject_) {
314 [&](SymbolRef &&symbol) {
315 return CompleteSubscripts(ArrayRef{symbol, std::move(subscripts)});
464 const Symbol &symbol{component.GetLastSymbol()};
465 if (int componentRank{symbol.Rank()}; componentRank > 0) {
468 componentRank, symbol.name(), baseRank);
541 if (const Symbol *symbol{
542 parser::GetLastName(arrElement.base).symbol}) {
543 const Symbol &ultimate{symbol->GetUltimate()};
563 // slice -- fix the substring and then convert to an intrinsic function
980 if (context_.HasError(n.symbol)) { // includes case of no symbol
983 const Symbol &ultimate{n.symbol->GetUltimate()};
1010 if (n.symbol->attrs().test(semantics::Attr::VOLATILE)) {
1015 n.source, DEREF(pure->symbol()).name());
1016 n.symbol->attrs().reset(semantics::Attr::VOLATILE);
1021 ResolveAssociations(*n.symbol))) { // C1002, C1014, C1231
1026 *n.symbol);
1028 return Designate(DataRef{*n.symbol});
1123 const Symbol &symbol{checked->GetLastSymbol()};
1125 DynamicType::From(symbol)}) {
1301 // will be converted to function call later or error reported
1303 if (const Symbol *symbol{GetLastSymbol(*baseExpr)}) {
1304 if (!context_.HasError(symbol)) {
1308 symbol->name());
1310 Say("'%s' is not an array"_err_en_US, symbol->name());
1312 context_.SetError(*symbol);
1334 [](SymbolRef &&symbol) { return NamedEntity{symbol}; },
1379 Symbol *sym{sc.component.symbol};
1508 const Symbol &symbol{reversed.front()};
1509 if (numCosubscripts != GetCorank(symbol)) {
1511 symbol.name(), GetCorank(symbol), numCosubscripts);
1866 if (const Symbol * symbol{bounds.name.thing.thing.symbol}) {
1867 if (auto dynamicType{DynamicType::From(symbol)}) {
1979 // Check if implicit conversion of expr to the symbol type is legal (if needed),
2001 if (semantics::Symbol *typeSymbol{structureType.symbol}) {
2065 const Symbol *symbol{nullptr};
2071 symbol = kw->v.symbol;
2072 if (!symbol) {
2077 symbol = &sym;
2081 if (!symbol) { // C7101
2102 symbol = &*parent;
2106 symbol->name());
2111 while (!symbol && nextAnonymous != components.end()) {
2115 symbol = &next;
2118 if (!symbol) {
2122 if (symbol) {
2124 if (auto msg{CheckAccessibleSymbol(innermost, *symbol)}) {
2129 std::find(components.begin(), components.end(), *symbol)};
2130 if (unavailable.find(symbol->name()) != unavailable.cend()) {
2135 symbol->name());
2136 } else if (symbol->test(Symbol::Flag::ParentComp)) {
2151 unavailable.insert(symbol->name());
2153 if (symbol->has<semantics::TypeParamDetails>()) {
2156 symbol->name());
2158 if (!(symbol->has<semantics::ProcEntityDetails>() ||
2159 symbol->has<semantics::ObjectEntityDetails>())) {
2162 if (IsPointer(*symbol)) { // C7104, C7105, C1594(4)
2164 context_, *symbol, *value, innermost);
2165 result.Add(*symbol, Fold(std::move(*value)));
2169 if (IsAllocatable(*symbol)) {
2173 result.Add(*symbol, Expr<SomeType>{NullPointer{}});
2182 symbol->name()),
2183 *symbol);
2189 symbol->name()),
2190 *symbol);
2197 symbol->name()),
2198 *symbol);
2201 } else if (const Symbol * pointer{FindPointerComponent(*symbol)};
2208 visible->name(), symbol->name(), pointer->name());
2219 *symbol, std::move(*value), IsAllocatable(*symbol))}) {
2220 if (auto componentShape{GetShape(GetFoldingContext(), *symbol)}) {
2226 GetRank(*valueShape), symbol->name()),
2227 *symbol);
2235 (IsDeferredShape(*symbol) ||
2241 symbol->name()),
2242 *symbol);
2245 result.Add(*symbol, std::move(*converted));
2255 symbol->name()),
2256 *symbol);
2258 } else if (auto symType{DynamicType::From(symbol)}) {
2259 if (IsAllocatable(*symbol) && symType->IsUnlimitedPolymorphic() &&
2267 valueType->AsFortran(), symbol->name(),
2269 *symbol);
2275 symbol->name(), symType->AsFortran()),
2276 *symbol);
2284 for (const Symbol &symbol : components) {
2285 if (!symbol.test(Symbol::Flag::ParentComp) &&
2286 unavailable.find(symbol.name()) == unavailable.cend()) {
2287 if (IsAllocatable(symbol)) {
2289 result.Add(symbol, Expr<SomeType>{NullPointer{}});
2291 const auto *object{symbol.detailsIf<semantics::ObjectEntityDetails>()};
2293 result.Add(symbol, common::Clone(*object->init()));
2294 } else if (IsPointer(symbol)) {
2295 result.Add(symbol, Expr<SomeType>{NullPointer{}});
2300 symbol.name()),
2301 symbol);
2389 return &binding->symbol();
2397 if (const Symbol *sym{sc.component.symbol}) {
2458 sc.component.symbol = const_cast<Symbol *>(sym);
2560 // Return false when the function results' types are both
2696 // Handles a forward reference to a module function from what must
2697 // be a specification expression. Return false if the symbol is
2699 const Symbol *ExpressionAnalyzer::ResolveForward(const Symbol &symbol) {
2700 if (context_.HasError(symbol)) {
2704 symbol.detailsIf<semantics::SubprogramNameDetails>()}) {
2706 // If this symbol is still a SubprogramNameDetails, we must be
2710 const semantics::Scope &scope{symbol.owner()};
2711 semantics::ResolveSpecificationParts(context_, symbol);
2713 if (auto iter{scope.find(symbol.name())}; iter != scope.cend()) {
2717 // When the symbol hasn't had its details updated, we must have
2718 // already been in the process of resolving the function's
2719 // specification part; but recursive function calls are not
2721 Say("The module function '%s' may not be referenced recursively in a specification expression"_err_en_US,
2722 symbol.name());
2723 context_.SetError(symbol);
2727 semantics::ResolveSpecificationParts(context_, symbol);
2728 CHECK(symbol.has<semantics::SubprogramDetails>());
2730 Say("The internal function '%s' may not be referenced in a specification expression"_err_en_US,
2731 symbol.name());
2732 context_.SetError(symbol);
2736 return &symbol;
2742 const Symbol &symbol, const ActualArguments &actuals,
2747 const Symbol &ultimate{symbol.GetUltimate()};
2816 return {&AccessSpecific(symbol, *nonElemental), false};
2818 return {&AccessSpecific(symbol, *elemental), false};
2821 if (const auto *parentScope{symbol.owner().GetDerivedTypeParent()}) {
2822 if (const Symbol *extended{parentScope->FindComponent(symbol.name())}) {
2836 if (!symbol.owner().IsGlobal() && !symbol.owner().IsDerivedType()) {
2837 for (const std::string &n : GetAllNames(context_, symbol.name())) {
2838 if (const Symbol *outer{symbol.owner().parent().FindSymbol(n)}) {
2854 return AccessSpecific(hosted->symbol(), specific);
2861 const Symbol &usedSymbol{useDetails->symbol()};
2872 used->symbol().owner().GetName().value().ToString() + "$" +
2885 const Symbol &symbol, bool dueToAmbiguity, bool isSubroutine) {
2888 : semantics::IsGenericDefinedOp(symbol)
2892 : "No specific function of generic '%s' matches the actual arguments"_err_en_US,
2893 symbol.name());
2917 const Symbol *symbol{name.symbol};
2918 if (context_.HasError(symbol)) {
2919 return std::nullopt; // also handles null symbol
2921 symbol = ResolveForward(*symbol);
2922 if (!symbol) {
2925 name.symbol = const_cast<Symbol *>(symbol);
2926 const Symbol &ultimate{symbol->GetUltimate()};
2934 auto pair{ResolveGeneric(*symbol, arguments, noAdjustment, isSubroutine,
2942 *symbol, *resolution, arguments, GetFoldingContext());
2945 name.symbol = const_cast<Symbol *>(resolution);
2952 resolution = symbol;
2962 CheckBadExplicitType(*specificCall, *symbol);
2968 EmitGenericResolutionError(*symbol, dueToAmbiguity, isSubroutine);
2992 // generic intrinsic function "has no effect" on the result type of a
3011 "The result type '%s' of the intrinsic function '%s' is not the explicit declared type '%s'"_warn_en_US,
3015 "Ignored declaration of intrinsic function '%s'"_en_US,
3036 "Assumed-length CHARACTER(*) function '%s' cannot call itself"_err_en_US,
3061 if (const Symbol *symbol{name.symbol}) {
3062 if (const auto *type{symbol->GetType()}) {
3064 return symbol;
3181 const Symbol &symbol{*std::get<semantics::SymbolRef>(callee->u)};
3183 // Structure constructor misparsed as function reference?
3187 semantics::DerivedTypeSpec dtSpec{name->source, symbol.GetUltimate()};
3199 if (!context_.HasError(symbol)) {
3201 Say("'%s' is called like a function but is not a procedure"_err_en_US,
3202 symbol.name()),
3203 symbol);
3204 context_.SetError(symbol);
3360 parser::CharBlock callSite, const Symbol *symbol) {
3361 return symbol && symbol->owner().IsGlobal() &&
3362 symbol->has<semantics::SubprogramDetails>() &&
3363 (!symbol->scope() /*ENTRY*/ ||
3364 !symbol->scope()->sourceRange().Contains(callSite));
3426 "Assumed-length character function must be defined with a length to be called"_err_en_US);
3438 procSymbol->name(), DEREF(pure->symbol()).name());
3462 if (const semantics::Symbol *symbol{GetLastSymbol(*operand)}) {
3463 if (const semantics::Symbol *result{FindFunctionResult(*symbol)}) {
3465 Say("A function reference that returns a procedure "
3530 // intrinsic function.
3636 // If the actuals match one of the specific procedures, return a function ref.
3750 // Returns true if a parsed function reference should be converted
3754 // Emit message if the function reference fix will end up an array element
3764 if (!name->symbol) {
3766 } else if (name->symbol->Rank() == 0) {
3767 if (const Symbol *function{
3768 semantics::IsFunctionResultWithSameNameAsFunction(*name->symbol)}) {
3770 function->flags().test(Symbol::Flag::StmtFunction)
3771 ? "Recursive call to statement function '%s' is not allowed"_err_en_US
3774 AttachDeclaration(&msg, *function);
3775 name->symbol = const_cast<Symbol *>(function);
3783 if (name->symbol) {
3784 AttachDeclaration(&msg, *name->symbol);
3792 // A(1) as a function reference into an array reference.
3794 // function call resolution fails.
3814 [&](parser::Name &name) { return name.symbol; },
3816 return pcr.v.thing.component.symbol;
3820 Symbol &symbol{origSymbol->GetUltimate()};
3821 if (symbol.has<semantics::ObjectEntityDetails>() ||
3822 symbol.has<semantics::AssocEntityDetails>()) {
3824 // pointer as per C1105 so this cannot be a function reference.
3831 DIE("can't fix misparsed function as array reference");
3867 // A misparsed function reference is really a structure
4178 if (const Symbol *symbol{proc.GetSymbol()}) {
4179 if (!ResolveForward(*symbol)) {
4240 const Symbol *symbol{GetLastSymbol(*expr)};
4241 if (!symbol) {
4244 } else if (IsProcedure(*symbol)) {
4247 symbol->name())}) {
4248 if (auto *subp{symbol->detailsIf<semantics::SubprogramDetails>()}) {
4257 x, "Assignment to '%s' is not allowed"_err_en_US, symbol->name());
4283 "alternate return specification may not appear on function reference"_err_en_US);
4456 if (Symbol *symbol{scope.FindSymbol(oprName)}) {
4458 parser::Name name{symbol->name(), symbol};
4463 inaccessible = CheckAccessibleSymbol(scope, *symbol);
4467 hit.push_back(symbol);
4496 for (const Symbol *symbol : hit) {
4497 AttachDeclaration(*msg, *symbol);
4549 MaybeExpr ArgumentAnalyzer::TryBoundOp(const Symbol &symbol, int passIndex) {
4551 const Symbol *proc{GetBindingResolution(GetType(passIndex), symbol)};
4553 proc = &symbol;
4651 if (const Symbol *symbol{scope.FindSymbol(oprName)}) {
4654 context_.ResolveGeneric(*symbol, actuals_, noAdjustment, true).first;
4702 } else if (const Symbol *symbol{actual->GetAssumedTypeDummy()}) {
4703 os << "- assumed type: " << symbol->name().ToString() << '\n';
4745 if (name->symbol && semantics::IsAssumedSizeArray(*name->symbol)) {
4949 if (const auto dynamicType{evaluate::DynamicType::From(*name.symbol)}) {