Skip to content

Commit

Permalink
[flang] Fix assert on bad character kind
Browse files Browse the repository at this point in the history
When we report an error for a bad character kind, don't keep it in the
`DeclTypeSpec`. Otherwise there could be further problems. In this case,
`ComputeOffsets()` got an assertion error because we didn't recognize
`CHARACTER(*,8)` as needing a descriptor because of the bad kind.

Fixes https://bugs.llvm.org/show_bug.cgi?id=47173

Differential Revision: https://reviews.llvm.org/D86357
  • Loading branch information
tskeith committed Aug 22, 2020
1 parent bb894b9 commit c0c3caf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions flang/lib/Semantics/resolve-names.cpp
Expand Up @@ -3461,6 +3461,7 @@ void DeclarationVisitor::Post(const parser::CharSelector::LengthAndKind &x) {
TypeCategory::Character, *intKind)) { // C715, C719
Say(currStmtSource().value(),
"KIND value (%jd) not valid for CHARACTER"_err_en_US, *intKind);
charInfo_.kind = std::nullopt; // prevent further errors
}
if (x.length) {
charInfo_.length = GetParamValue(*x.length, common::TypeParamAttr::Len);
Expand Down
6 changes: 6 additions & 0 deletions flang/test/Semantics/kinds02.f90
Expand Up @@ -83,3 +83,9 @@
!ERROR: CHARACTER(KIND=8) is not a supported type
character(len=*), parameter :: cvar11 = 8_"abcd"
end program

subroutine s(a, b)
character(*,2) :: a
!ERROR: KIND value (8) not valid for CHARACTER
character(*,8) :: b
end

0 comments on commit c0c3caf

Please sign in to comment.