Skip to content

[flang] Catch inappropriate attributes for PARAMETERs #85588

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

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions flang/lib/Semantics/check-declarations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,11 @@ void CheckHelper::CheckObjectEntity(
const Symbol &symbol, const ObjectEntityDetails &details) {
CheckSymbolType(symbol);
CheckArraySpec(symbol, details.shape());
CheckConflicting(symbol, Attr::ALLOCATABLE, Attr::PARAMETER);
CheckConflicting(symbol, Attr::ASYNCHRONOUS, Attr::PARAMETER);
CheckConflicting(symbol, Attr::SAVE, Attr::PARAMETER);
CheckConflicting(symbol, Attr::TARGET, Attr::PARAMETER);
CheckConflicting(symbol, Attr::VOLATILE, Attr::PARAMETER);
Check(details.shape());
Check(details.coshape());
if (details.shape().Rank() > common::maxRank) {
Expand Down
14 changes: 14 additions & 0 deletions flang/test/Semantics/declarations02.f90
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ module m
integer, parameter :: x3 = 1
bind(c) :: x3

!ERROR: 'x4' may not have both the ALLOCATABLE and PARAMETER attributes
!ERROR: 'x4' may not have both the ASYNCHRONOUS and PARAMETER attributes
!ERROR: 'x4' may not have both the SAVE and PARAMETER attributes
!ERROR: 'x4' may not have both the TARGET and PARAMETER attributes
!ERROR: 'x4' may not have both the VOLATILE and PARAMETER attributes
!ERROR: The entity 'x4' with an explicit SAVE attribute must be a variable, procedure pointer, or COMMON block
!ERROR: An entity may not have the ASYNCHRONOUS attribute unless it is a variable
integer, parameter :: x4 = 1
allocatable x4
asynchronous x4
save x4
target x4
volatile x4

type :: my_type1
integer :: x4
end type
Expand Down