Skip to content

Commit 129db4d

Browse files
authored
[flang] Catch both EXTERNAL and INTRINSIC on type declaration stmt (#150254)
The EXTERNAL and INTRINSIC attributes can't both appear on the same type declarations statement. Fixes #149771.
1 parent f6a6cdd commit 129db4d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

flang/lib/Semantics/resolve-names.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2351,7 +2351,8 @@ bool AttrsVisitor::IsConflictingAttr(Attr attrName) {
23512351
HaveAttrConflict(attrName, Attr::PASS, Attr::NOPASS) || // C781
23522352
HaveAttrConflict(attrName, Attr::PURE, Attr::IMPURE) ||
23532353
HaveAttrConflict(attrName, Attr::PUBLIC, Attr::PRIVATE) ||
2354-
HaveAttrConflict(attrName, Attr::RECURSIVE, Attr::NON_RECURSIVE);
2354+
HaveAttrConflict(attrName, Attr::RECURSIVE, Attr::NON_RECURSIVE) ||
2355+
HaveAttrConflict(attrName, Attr::INTRINSIC, Attr::EXTERNAL);
23552356
}
23562357
bool AttrsVisitor::CheckAndSet(Attr attrName) {
23572358
if (IsConflictingAttr(attrName) || IsDuplicateAttr(attrName)) {

flang/test/Semantics/resolve126.f90

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
! RUN: %python %S/test_errors.py %s %flang_fc1
2+
!ERROR: Attributes 'INTRINSIC' and 'EXTERNAL' conflict with each other
3+
real, external, intrinsic :: exp
4+
!ERROR: Symbol 'sin' cannot have both EXTERNAL and INTRINSIC attributes
5+
external sin
6+
intrinsic sin
7+
end

0 commit comments

Comments
 (0)