Skip to content
Open
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
4 changes: 4 additions & 0 deletions flang/lib/Semantics/expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2076,11 +2076,15 @@ MaybeExpr ArrayConstructorContext::ToExpr() {

MaybeExpr ExpressionAnalyzer::Analyze(const parser::ArrayConstructor &array) {
const parser::AcSpec &acSpec{array.v};
bool hadAnyFatalError{context_.AnyFatalError()};
ArrayConstructorContext acContext{
*this, AnalyzeTypeSpec(acSpec.type, GetFoldingContext())};
for (const parser::AcValue &value : acSpec.values) {
acContext.Add(value);
}
if (!hadAnyFatalError && context_.AnyFatalError()) {
return std::nullopt;
}
return acContext.ToExpr();
}

Expand Down
10 changes: 10 additions & 0 deletions flang/test/Semantics/bug127425.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
! RUN: %python %S/test_errors.py %s %flang_fc1

program main
implicit none
integer :: ja, jb, j3, j4, j5
pointer (j1,ja)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add implicit none and add explicit type declarations for better test readability?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review.
I've added explicit type declarations.

pointer (j2,jb)
!ERROR: Values in array constructor must have the same declared type when no explicit type appears
if (any((/j1,j2,j3,j4,j5/)/=(/1,2,3,4,5/))) print *,'fail'
end program main