summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorc8ef <c8ef@outlook.com>2025-07-21 14:57:47 +0000
committerc8ef <c8ef@outlook.com>2025-07-21 14:57:47 +0000
commit7ce2a13b4d9246f9733e55ab849d0ccd4fd67470 (patch)
tree17551917cf8ac43320764c7bdee15be953211988
parent5d3b0578d8d51947a6878d65249174de86105073 (diff)
[flang] intrinsic and external are mutually exclusiveusers/c8ef/_flang_intrinsic_and_external_are_mutually_exclusive
-rw-r--r--flang/lib/Semantics/resolve-names.cpp14
-rw-r--r--flang/test/Semantics/null-init.f901
-rw-r--r--flang/test/Semantics/resolve-intrinsic-external.f909
3 files changed, 10 insertions, 14 deletions
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index b3268605e7c0..cb59b3f88127 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -2351,6 +2351,7 @@ bool AttrsVisitor::IsConflictingAttr(Attr attrName) {
HaveAttrConflict(attrName, Attr::PASS, Attr::NOPASS) || // C781
HaveAttrConflict(attrName, Attr::PURE, Attr::IMPURE) ||
HaveAttrConflict(attrName, Attr::PUBLIC, Attr::PRIVATE) ||
+ HaveAttrConflict(attrName, Attr::EXTERNAL, Attr::INTRINSIC) || // C840
HaveAttrConflict(attrName, Attr::RECURSIVE, Attr::NON_RECURSIVE);
}
bool AttrsVisitor::CheckAndSet(Attr attrName) {
@@ -3311,11 +3312,6 @@ bool ScopeHandler::CheckPossibleBadForwardRef(const Symbol &symbol) {
void ScopeHandler::MakeExternal(Symbol &symbol) {
if (!symbol.attrs().test(Attr::EXTERNAL)) {
SetImplicitAttr(symbol, Attr::EXTERNAL);
- if (symbol.attrs().test(Attr::INTRINSIC)) { // C840
- Say(symbol.name(),
- "Symbol '%s' cannot have both EXTERNAL and INTRINSIC attributes"_err_en_US,
- symbol.name());
- }
}
}
@@ -5606,10 +5602,6 @@ bool DeclarationVisitor::Pre(const parser::ExternalStmt &x) {
SayWithDecl(
name, *symbol, "EXTERNAL attribute not allowed on '%s'"_err_en_US);
}
- } else if (symbol->attrs().test(Attr::INTRINSIC)) { // C840
- Say(symbol->name(),
- "Symbol '%s' cannot have both INTRINSIC and EXTERNAL attributes"_err_en_US,
- symbol->name());
}
}
return false;
@@ -5637,10 +5629,6 @@ void DeclarationVisitor::DeclareIntrinsic(const parser::Name &name) {
} else if (!ConvertToProcEntity(symbol, name.source)) {
SayWithDecl(
name, symbol, "INTRINSIC attribute not allowed on '%s'"_err_en_US);
- } else if (symbol.attrs().test(Attr::EXTERNAL)) { // C840
- Say(symbol.name(),
- "Symbol '%s' cannot have both EXTERNAL and INTRINSIC attributes"_err_en_US,
- symbol.name());
} else {
if (symbol.GetType()) {
// These warnings are worded so that they should make sense in either
diff --git a/flang/test/Semantics/null-init.f90 b/flang/test/Semantics/null-init.f90
index d01ad75a75a1..3f81bd907eab 100644
--- a/flang/test/Semantics/null-init.f90
+++ b/flang/test/Semantics/null-init.f90
@@ -30,7 +30,6 @@ module m5
end module
module m6
- !ERROR: Symbol 'null' cannot have both INTRINSIC and EXTERNAL attributes
integer, pointer :: p => null()
external :: null
end module
diff --git a/flang/test/Semantics/resolve-intrinsic-external.f90 b/flang/test/Semantics/resolve-intrinsic-external.f90
new file mode 100644
index 000000000000..269ef37207c1
--- /dev/null
+++ b/flang/test/Semantics/resolve-intrinsic-external.f90
@@ -0,0 +1,9 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1
+
+real function eval(x, n)
+ real :: x
+ integer :: n
+ !ERROR: Attributes 'EXTERNAL' and 'INTRINSIC' conflict with each other
+ real, external, intrinsic :: exp
+ eval = 1.0
+end function eval