[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 https://github.com/llvm/llvm-project/issues/149771.
This commit is contained in:
Peter Klausler 2025-07-25 14:48:01 -07:00 committed by GitHub
parent f6a6cdd15c
commit 129db4dc3e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View File

@ -2351,7 +2351,8 @@ bool AttrsVisitor::IsConflictingAttr(Attr attrName) {
HaveAttrConflict(attrName, Attr::PASS, Attr::NOPASS) || // C781 HaveAttrConflict(attrName, Attr::PASS, Attr::NOPASS) || // C781
HaveAttrConflict(attrName, Attr::PURE, Attr::IMPURE) || HaveAttrConflict(attrName, Attr::PURE, Attr::IMPURE) ||
HaveAttrConflict(attrName, Attr::PUBLIC, Attr::PRIVATE) || HaveAttrConflict(attrName, Attr::PUBLIC, Attr::PRIVATE) ||
HaveAttrConflict(attrName, Attr::RECURSIVE, Attr::NON_RECURSIVE); HaveAttrConflict(attrName, Attr::RECURSIVE, Attr::NON_RECURSIVE) ||
HaveAttrConflict(attrName, Attr::INTRINSIC, Attr::EXTERNAL);
} }
bool AttrsVisitor::CheckAndSet(Attr attrName) { bool AttrsVisitor::CheckAndSet(Attr attrName) {
if (IsConflictingAttr(attrName) || IsDuplicateAttr(attrName)) { if (IsConflictingAttr(attrName) || IsDuplicateAttr(attrName)) {

View File

@ -0,0 +1,7 @@
! RUN: %python %S/test_errors.py %s %flang_fc1
!ERROR: Attributes 'INTRINSIC' and 'EXTERNAL' conflict with each other
real, external, intrinsic :: exp
!ERROR: Symbol 'sin' cannot have both EXTERNAL and INTRINSIC attributes
external sin
intrinsic sin
end