Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: FIR Merge - PR1: Add ASTBuilder structure to help lowering the parse-tree #5

Open
wants to merge 31 commits into
base: flang-master
Choose a base branch
from
Open
Changes from 2 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0c3c39d
[OpenMP] Name Resolution for OpenMP constructs (#940)
gpupuck Jan 28, 2020
3f37e0d
Remove `default` case for OmpSectionsDirective (only two enum values)
gpupuck Jan 28, 2020
d98bf84
Merge pull request #960 from flang-compiler/by-remove-default
gpupuck Jan 28, 2020
d2294ff
Semantic checks for deallocating entities with IMPURE FINAL procedures
psteinfeld Jan 27, 2020
61da1f9
Merge pull request #954 from flang-compiler/ps-impure-final
psteinfeld Jan 29, 2020
aa0a088
Fix another bug checking simple contiguity
tskeith Jan 28, 2020
cd371e9
Merge pull request #961 from flang-compiler/tsk-contig2
tskeith Jan 30, 2020
889f909
Explanation of how to implement a semantic check
psteinfeld Jan 16, 2020
bedca14
Merge pull request #939 from flang-compiler/ps-dev-story
psteinfeld Feb 3, 2020
4542cb5
Fix template step limit issue with clang
jeanPerier Feb 4, 2020
c3f1774
Initial buffer framing code
klausler Jan 24, 2020
003b664
Merge pull request #950 from flang-compiler/pmk-frame
klausler Feb 4, 2020
d4cd378
Merge pull request #968 from flang-compiler/jpr-fix-clang-template-st…
jeanPerier Feb 5, 2020
572a57d
[OpenMP] Predetermined rules for loop index variables (#962)
gpupuck Feb 5, 2020
a1a95bf
Semantic checks for C702
psteinfeld Feb 6, 2020
351a7d5
Merge pull request #973 from flang-compiler/ps-c702
psteinfeld Feb 7, 2020
16543d2
Fix issues comming from clang-10 warnings
jeanPerier Feb 6, 2020
90e6448
Merge pull request #972 from flang-compiler/jpr-clang-10-warnings
jeanPerier Feb 10, 2020
c342575
Fix compilation error on macOS
tskeith Feb 10, 2020
204c67d
Merge pull request #977 from flang-compiler/tsk-osx-error
tskeith Feb 10, 2020
75adddd
Updated the description of `evaluate::Expr` types
psteinfeld Feb 3, 2020
92884fa
Merge pull request #979 from flang-compiler/ps-dev-story
psteinfeld Feb 11, 2020
49a64c4
Semantic checks for constraints on types
psteinfeld Feb 10, 2020
2efdf12
Merge pull request #978 from flang-compiler/ps-types
psteinfeld Feb 11, 2020
9c4bba1
Progress on Fortran I/O runtime
klausler Feb 5, 2020
47ed180
Merge pull request #982 from flang-compiler/pmk-more-io
klausler Feb 13, 2020
403faf8
Add zlib to drone files so that linking LLVM works. (#983)
DavidTruby Feb 14, 2020
5dd0b0b
Semantic check for C708
psteinfeld Feb 11, 2020
4d4b375
Merge pull request #981 from flang-compiler/ps-c708
psteinfeld Feb 14, 2020
00d8d51
Add clang-format files for FIR source (LLVM style)
jeanPerier Jan 21, 2020
edb0943
Add Pre-FIR Tree structure to help lowering the parse-tree
jeanPerier Jan 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/semantics/check-declarations.cpp
Original file line number Diff line number Diff line change
@@ -495,7 +495,7 @@ void CheckHelper::CheckDerivedType(
}
if (const DeclTypeSpec * parent{FindParentTypeSpec(symbol)}) {
const DerivedTypeSpec *parentDerived{parent->AsDerived()};
if (!IsExtensibleType(parentDerived)) {
if (!IsExtensibleType(parentDerived)) { // C705
messages_.Say("The parent type is not extensible"_err_en_US);
}
if (!symbol.attrs().test(Attr::ABSTRACT) && parentDerived &&
33 changes: 29 additions & 4 deletions lib/semantics/resolve-names.cpp
Original file line number Diff line number Diff line change
@@ -343,6 +343,7 @@ class DeclTypeSpecVisitor : public AttrsVisitor {
}
KindExpr GetKindParamExpr(
TypeCategory, const std::optional<parser::KindSelector> &);
void CheckForAbstractType(const Symbol &typeSymbol);

private:
State state_;
@@ -731,7 +732,9 @@ class DeclarationVisitor : public ArraySpecVisitor,
void Post(const parser::LengthSelector &);
bool Pre(const parser::KindParam &);
bool Pre(const parser::DeclarationTypeSpec::Type &);
void Post(const parser::DeclarationTypeSpec::Type &);
bool Pre(const parser::DeclarationTypeSpec::Class &);
void Post(const parser::DeclarationTypeSpec::Class &);
bool Pre(const parser::DeclarationTypeSpec::Record &);
void Post(const parser::DerivedTypeSpec &);
bool Pre(const parser::DerivedTypeDef &);
@@ -1590,9 +1593,7 @@ void DeclTypeSpecVisitor::Post(const parser::TypeSpec &typeSpec) {
case DeclTypeSpec::Character: typeSpec.declTypeSpec = spec; break;
case DeclTypeSpec::TypeDerived:
if (const DerivedTypeSpec * derived{spec->AsDerived()}) {
if (derived->typeSymbol().attrs().test(Attr::ABSTRACT)) {
Say("ABSTRACT derived type may not be used here"_err_en_US);
}
CheckForAbstractType(derived->typeSymbol()); // C703
typeSpec.declTypeSpec = spec;
}
break;
@@ -1613,6 +1614,12 @@ void DeclTypeSpecVisitor::MakeNumericType(TypeCategory category, int kind) {
SetDeclTypeSpec(context().MakeNumericType(category, kind));
}

void DeclTypeSpecVisitor::CheckForAbstractType(const Symbol &typeSymbol) {
if (typeSymbol.attrs().test(Attr::ABSTRACT)) {
Say("ABSTRACT derived type may not be used here"_err_en_US);
}
}

void DeclTypeSpecVisitor::Post(const parser::DeclarationTypeSpec::ClassStar &) {
SetDeclTypeSpec(context().globalScope().MakeClassStarType());
}
@@ -3287,11 +3294,29 @@ bool DeclarationVisitor::Pre(const parser::DeclarationTypeSpec::Type &) {
return true;
}

void DeclarationVisitor::Post(const parser::DeclarationTypeSpec::Type &type) {
const parser::Name &derivedName{std::get<parser::Name>(type.derived.t)};
if (const Symbol * derivedSymbol{derivedName.symbol}) {
CheckForAbstractType(*derivedSymbol); // C706
}
}

bool DeclarationVisitor::Pre(const parser::DeclarationTypeSpec::Class &) {
SetDeclTypeSpecCategory(DeclTypeSpec::Category::ClassDerived);
return true;
}

void DeclarationVisitor::Post(
const parser::DeclarationTypeSpec::Class &parsedClass) {
const auto &typeName{std::get<parser::Name>(parsedClass.derived.t)};
if (auto spec{ResolveDerivedType(typeName)};
spec && !IsExtensibleType(&*spec)) { // C705
SayWithDecl(typeName, *typeName.symbol,
"Non-extensible derived type '%s' may not be used with CLASS"
" keyword"_err_en_US);
}
}

bool DeclarationVisitor::Pre(const parser::DeclarationTypeSpec::Record &) {
// TODO
return true;
@@ -4501,7 +4526,7 @@ ParamValue DeclarationVisitor::GetParamValue(
const parser::TypeParamValue &x, common::TypeParamAttr attr) {
return std::visit(
common::visitors{
[=](const parser::ScalarIntExpr &x) {
[=](const parser::ScalarIntExpr &x) { // C704
return ParamValue{EvaluateIntExpr(x), attr};
},
[=](const parser::Star &) { return ParamValue::Assumed(attr); },
1 change: 1 addition & 0 deletions test/semantics/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -100,6 +100,7 @@ set(ERROR_TESTS
resolve67.f90
resolve68.f90
resolve69.f90
resolve70.f90
stop01.f90
structconst01.f90
structconst02.f90
2 changes: 1 addition & 1 deletion test/semantics/allocate04.f90
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ subroutine C933_b(n)
allocate(p3%y)
!ERROR: Either type-spec or source-expr must appear in ALLOCATE when allocatable object is of abstract type
allocate(p4(2)%y)
!WRONG allocate(Base:: u1) !C703
!WRONG allocate(Base:: u1)

! No error expected
allocate(real:: u1, u2(2))
1 change: 1 addition & 0 deletions test/semantics/resolve52.f90
Original file line number Diff line number Diff line change
@@ -114,6 +114,7 @@ module m7
end type
contains
subroutine s(x)
!ERROR: Non-extensible derived type 't' may not be used with CLASS keyword
class(t) :: x
end
end
9 changes: 9 additions & 0 deletions test/semantics/resolve69.f90
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
subroutine s1()
! C701 (R701) The type-param-value for a kind type parameter shall be a
! constant expression.
!
! C702 (R701) A colon shall not be used as a type-param-value except in the
! declaration of an entity that has the POINTER or ALLOCATABLE attribute.
!
! C704 (R703) In a declaration-type-spec, every type-param-value that is
! not a colon or an asterisk shall be a specification expression.
! Section 10.1.11 defines specification expressions
!
integer, parameter :: constVal = 1
integer :: nonConstVal = 1
!ERROR: Invalid specification expression: reference to local entity 'nonconstval'
@@ -20,6 +26,9 @@ subroutine s1()
!OK because of the allocatable attribute
character(:), allocatable :: colonString3

!ERROR: Must have INTEGER type, but is REAL(4)
character(3.5) :: badParamValue

type derived(typeKind, typeLen)
integer, kind :: typeKind
integer, len :: typeLen
58 changes: 58 additions & 0 deletions test/semantics/resolve70.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
! C703 (R702) The derived-type-spec shall not specify an abstract type (7.5.7).
! This constraint refers to the derived-type-spec in a type-spec. A type-spec
! can appear in an ALLOCATE statement, an ac-spec for an array constructor, and
! in the type specifier of a TYPE GUARD statement
!
! C706 TYPE(derived-type-spec) shall not specify an abstract type (7.5.7).
! This is for a declaration-type-spec
!
! C796 (R756) The derived-type-spec shall not specify an abstract type (7.5.7).
!
! C705 (R703) In a declaration-type-spec that uses the CLASS keyword,
! derived-type-spec shall specify an extensible type (7.5.7).
subroutine s()
type, abstract :: abstractType
end type abstractType

type, extends(abstractType) :: concreteType
end type concreteType

! declaration-type-spec
!ERROR: ABSTRACT derived type may not be used here
type (abstractType), allocatable :: abstractVar

! ac-spec for an array constructor
!ERROR: ABSTRACT derived type may not be used here
!ERROR: ABSTRACT derived type may not be used here
type (abstractType), parameter :: abstractArray(*) = (/ abstractType :: /)

class(*), allocatable :: selector

! Structure constructor
!ERROR: ABSTRACT derived type may not be used here
!ERROR: ABSTRACT derived type 'abstracttype' may not be used in a structure constructor
type (abstractType) :: abstractVar1 = abstractType()

! Allocate statement
!ERROR: ABSTRACT derived type may not be used here
allocate(abstractType :: abstractVar)

select type(selector)
! Type specifier for a type guard statement
!ERROR: ABSTRACT derived type may not be used here
type is (abstractType)
end select
end subroutine s

subroutine s1()
type :: extensible
end type
type, bind(c) :: inextensible
end type

! This one's OK
class(extensible) :: y

!ERROR: Non-extensible derived type 'inextensible' may not be used with CLASS keyword
class(inextensible) :: x
end subroutine s1
4 changes: 3 additions & 1 deletion test/semantics/structconst01.f90
Original file line number Diff line number Diff line change
@@ -3,6 +3,8 @@
! errors meant to be caught by expression semantic analysis, as well as
! acceptable use cases.
! Type parameters are used here to make the parses unambiguous.
! C796 (R756) The derived-type-spec shall not specify an abstract type (7.5.7).
! This refers to a derived-type-spec used in a structure constructor

module module1
type :: type1(j)
@@ -29,7 +31,7 @@ subroutine type2arg(x)
type(type2(0,0)), intent(in) :: x
end subroutine type2arg
subroutine abstractarg(x)
type(abstract(0)), intent(in) :: x
class(abstract(0)), intent(in) :: x
end subroutine abstractarg
subroutine errors
call type1arg(type1(0)())