Skip to content

Commit

Permalink
Add note to new warnings about being an error in the future
Browse files Browse the repository at this point in the history
Adjusts the warnings from PRs chapel-lang#22697 chapel-lang#22745 and chapel-lang#22784 to include a note
about the warning possibly being an error in the future when compiling
with `--warn-unstable`.

---
Signed-off-by: Michael Ferguson <[email protected]>
  • Loading branch information
mppf committed Aug 4, 2023
1 parent 5f7971d commit 2973722
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions compiler/passes/scopeResolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ static void checkClass(AggregateType* ct) {
if (!ct->symbol->hasFlag(FLAG_SUPERCLASS_MARKED_GENERIC) &&
parent->isGeneric() && !parent->isGenericWithDefaults()) {
USR_WARN(ct->symbol, "missing '(?)' after a generic parent class");
if (fWarnUnstable) {
USR_PRINT("this warning may be an error in the future");
}
}
if (ct->symbol->hasFlag(FLAG_SUPERCLASS_MARKED_GENERIC) &&
!parent->isGeneric()) {
Expand Down
6 changes: 6 additions & 0 deletions compiler/resolution/functionResolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13861,6 +13861,9 @@ void checkSurprisingGenericDecls(Symbol* sym, Expr* typeExpr,
USR_PRINT("consider adding 'owned', 'shared', or 'borrowed'");
USR_PRINT("if generic memory management is desired, "
"use a 'type' field to store the class type");
if (fWarnUnstable) {
USR_PRINT("this warning may be an error in the future");
}
}

// consider the class type ignoring management for
Expand Down Expand Up @@ -13949,6 +13952,9 @@ void checkSurprisingGenericDecls(Symbol* sym, Expr* typeExpr,
fieldOrVar);
USR_PRINT(sym, "for example with '%s'", s.c_str());
}
if (fWarnUnstable) {
USR_PRINT("this warning may be an error in the future");
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions test/classes/ferguson/inherit-generic-q.compopts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--warn-unstable
1 change: 1 addition & 0 deletions test/classes/ferguson/inherit-generic-q.good
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
inherit-generic-q.chpl:4: warning: missing '(?)' after a generic parent class
note: this warning may be an error in the future
inherit-generic-q.chpl:8: error: '(?)' after a concrete parent class
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--warn-unstable
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
warn-field-generic-declared-type.chpl:12: warning: field is declared with generic memory management
note: consider adding 'owned', 'shared', or 'borrowed'
note: if generic memory management is desired, use a 'type' field to store the class type
note: this warning may be an error in the future
warn-field-generic-declared-type.chpl:21: warning: field is declared with generic memory management
note: consider adding 'owned', 'shared', or 'borrowed'
note: if generic memory management is desired, use a 'type' field to store the class type
note: this warning may be an error in the future
warn-field-generic-declared-type.chpl:30: warning: field is declared with generic memory management
note: consider adding 'owned', 'shared', or 'borrowed'
note: if generic memory management is desired, use a 'type' field to store the class type
note: this warning may be an error in the future
warn-field-generic-declared-type.chpl:56: warning: please use '?' when declaring a field with generic type
warn-field-generic-declared-type.chpl:56: note: for example with 'GR(?)'
note: this warning may be an error in the future
warn-field-generic-declared-type.chpl:96: warning: please use 'domain(?)' for the type of a generic field storing any domain
note: this warning may be an error in the future
(myfield = 0)
(myfield = {}) : A(owned MyClass?)
(myfield = nil) : B(owned MyClass?)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--warn-unstable
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
warn-generic-var-field-no-q.chpl:6: warning: please use '?' when declaring a field with generic type
warn-generic-var-field-no-q.chpl:6: note: for example with 'GR(?)'
note: this warning may be an error in the future
warn-generic-var-field-no-q.chpl:10: warning: please use '?' when declaring a field with generic type
warn-generic-var-field-no-q.chpl:10: note: for example with 'GR(?)'
note: this warning may be an error in the future
warn-generic-var-field-no-q.chpl:14: warning: please use '?' when declaring a field with generic type
warn-generic-var-field-no-q.chpl:14: note: for example with 'GR(?)'
note: this warning may be an error in the future
warn-generic-var-field-no-q.chpl:25: warning: please use '?' when declaring a variable with generic type
warn-generic-var-field-no-q.chpl:25: note: for example with 'GR(?)'
note: this warning may be an error in the future
warn-generic-var-field-no-q.chpl:27: warning: please use '?' when declaring a variable with generic type
warn-generic-var-field-no-q.chpl:27: note: for example with 'GR(?)'
note: this warning may be an error in the future
warn-generic-var-field-no-q.chpl:34: warning: please use '?' when declaring a variable with generic type
warn-generic-var-field-no-q.chpl:34: note: for example with 'GR(?)'
note: this warning may be an error in the future
warn-generic-var-field-no-q.chpl:43: warning: please use '?' when declaring a variable with generic type
warn-generic-var-field-no-q.chpl:43: note: for example with 'GR(?)'
note: this warning may be an error in the future
warn-generic-var-field-no-q.chpl:20: error: done

0 comments on commit 2973722

Please sign in to comment.