[Chapel Merge] Add deprecated keyword to deprecate any symbol

Branch: refs/heads/master
Revision: cac6ad0
Author: lydia-duncan
Log Message:

Merge pull request #17815 from lydia-duncan/deprecatedKeyword

Add deprecated keyword to deprecate any symbol
[reviewed by @mppf, test directory name also discussed with @dlongnecke-cray]

We were previously able to deprecate a proc or iter by using a
compilerWarning within the body. This worked well, but
deprecating other symbols was more complicated and in some
cases impossible. This change adds new syntax to deprecate
a symbol, which can be applied to any symbol in a uniform way.
As an example,

module M { ... }

will use a default message of "M is deprecated" when M is
referenced. An explicit message can be specified by following
the new keyword with a string message, e.g.

deprecated "M is deprecated, please use N instead"
module M  { ... }

Resolves Cray/chapel-private#2008
Resolves #14396

Adds a new flag, FLAG_DEPRECATED, and a new field to the Symbol
base class, as well as a method on Symbol that will return either the
specified message or a computed default message. The deprecation
message value is copied over into the management class wrapper and
generic instantiations of a function.

Add productions to the parser to support the keyword and message
forms on module level symbols, class level symbols, and enum constants.
These forms allow the symbols to be built as normal, then attach the
deprecation message and flag to the symbol afterwards.

The remaining work is adding checks to the flag in all the places where a
symbol is resolved - when determining the symbol being referenced in an
import or use statement, when validating the only/except lists or import
list for unqualified access, when resolving enum qualified references, and
at function resolution. The latter involves excluding the generation of the
deprecation warning when we find a use within a compiler generated
function (like init=), which was triggering some additional errors.

While here, updated the compiler/next parser to also reflect the changes
(though not fully implement them yet)

Adds a number of tests of this new feature to ensure it behaves
appropriately, including:

  • with classes
  • with const variable declarations
  • that we don't allow deprecation warnings on forwarding statements,
    which is the only non-symbol syntax that the parser would allow currently
  • that a deprecated outer module will generate a warning if listed as part
    of the path of an inner module
  • with an enum declaration
  • with an enum's constant
  • with a field
  • with an initializer
  • with a method
  • with a module
  • with an operator
  • with a param variable declaration
  • with a proc
  • with a record
  • with a type alias declaration
  • with a variable declaration
  • with a variable declaration without specifying the message
  • with an enum constant without specifying the message
  • with a field without specifying the message (both with and without an explicit
  • various combinations of use in an import and use statement's limitation clause,
    including when renaming the symbol
  • and the ordering of the keyword relative to pragmas

Passed a full paratest with futures

Modified Files:
A test/deprecated-keyword/deprecateForwarding.chpl

A test/deprecated-keyword/deprecateForwarding.good
A test/deprecated-keyword/deprecatedOuterMod.chpl
A test/deprecated-keyword/deprecatedOuterMod.good
A test/deprecated-keyword/handleClass.chpl
A test/deprecated-keyword/handleClass.good
A test/deprecated-keyword/handleConst.chpl
A test/deprecated-keyword/handleConst.good
A test/deprecated-keyword/handleEnum.chpl
A test/deprecated-keyword/handleEnum.good
A test/deprecated-keyword/handleEnumConstants.chpl
A test/deprecated-keyword/handleEnumConstants.good
A test/deprecated-keyword/handleField.chpl
A test/deprecated-keyword/handleField.good
A test/deprecated-keyword/handleInitializer.chpl
A test/deprecated-keyword/handleInitializer.good
A test/deprecated-keyword/handleMethod.chpl
A test/deprecated-keyword/handleMethod.good
A test/deprecated-keyword/handleModule.chpl
A test/deprecated-keyword/handleModule.good
A test/deprecated-keyword/handleOperator.chpl
A test/deprecated-keyword/handleOperator.good
A test/deprecated-keyword/handleParam.chpl
A test/deprecated-keyword/handleParam.good
A test/deprecated-keyword/handleProc.chpl
A test/deprecated-keyword/handleProc.good
A test/deprecated-keyword/handleRecord.chpl
A test/deprecated-keyword/handleRecord.good
A test/deprecated-keyword/handleType.chpl
A test/deprecated-keyword/handleType.good
A test/deprecated-keyword/handleVar.chpl
A test/deprecated-keyword/handleVar.good
A test/deprecated-keyword/noMsg.chpl
A test/deprecated-keyword/noMsg.good
A test/deprecated-keyword/noMsgEnumConstant.chpl
A test/deprecated-keyword/noMsgEnumConstant.good
A test/deprecated-keyword/noMsgField.chpl
A test/deprecated-keyword/noMsgField.good
A test/deprecated-keyword/noMsgField2.chpl
A test/deprecated-keyword/noMsgField2.good
A test/deprecated-keyword/symbolInImportClause.chpl
A test/deprecated-keyword/symbolInImportClause.good
A test/deprecated-keyword/symbolInImportClause2.chpl
A test/deprecated-keyword/symbolInImportClause2.good
A test/deprecated-keyword/symbolInImportClauseRenamed.chpl
A test/deprecated-keyword/symbolInImportClauseRenamed.good
A test/deprecated-keyword/symbolInImportClauseRenamed2.chpl
A test/deprecated-keyword/symbolInImportClauseRenamed2.good
A test/deprecated-keyword/symbolInUseClause.chpl
A test/deprecated-keyword/symbolInUseClause.good
A test/deprecated-keyword/symbolInUseClause2.chpl
A test/deprecated-keyword/symbolInUseClause2.good
A test/deprecated-keyword/symbolInUseClauseRenamed.chpl
A test/deprecated-keyword/symbolInUseClauseRenamed.good
A test/deprecated-keyword/withPragma.chpl
A test/deprecated-keyword/withPragma.good
M compiler/AST/AggregateType.cpp
M compiler/AST/FnSymbol.cpp
M compiler/AST/ImportStmt.cpp
M compiler/AST/UseStmt.cpp
M compiler/AST/build.cpp
M compiler/AST/stmt.cpp
M compiler/AST/symbol.cpp
M compiler/include/bison-chapel.h
M compiler/include/build.h
M compiler/include/flags_list.h
M compiler/include/flex-chapel.h
M compiler/include/symbol.h
M compiler/next/lib/frontend/Parser/chapel.ypp
M compiler/parser/bison-chapel.cpp
M compiler/parser/chapel.lex
M compiler/parser/chapel.ypp
M compiler/parser/flex-chapel.cpp
M compiler/passes/ResolveScope.cpp
M compiler/passes/buildDefaultFunctions.cpp
M compiler/passes/scopeResolve.cpp
M compiler/resolution/functionResolution.cpp

Compare: https://github.com/chapel-lang/chapel/compare/92038bb1654a...cac6ad0b59a6