if (streaming_p ())
WU (((lang_tree_node *)t)->trait_expression.kind);
break;
+
+ case TU_LOCAL_ENTITY:
+ WT (((lang_tree_node *)t)->tu_local_entity.name);
+ if (state)
+ state->write_location
+ (*this, ((lang_tree_node *)t)->tu_local_entity.loc);
+ break;
}
if (CODE_CONTAINS_STRUCT (code, TS_TYPED))
RT (((lang_tree_node *)t)->trait_expression.type2);
RUC (cp_trait_kind, ((lang_tree_node *)t)->trait_expression.kind);
break;
+
+ case TU_LOCAL_ENTITY:
+ RT (((lang_tree_node *)t)->tu_local_entity.name);
+ ((lang_tree_node *)t)->tu_local_entity.loc
+ = state->read_location (*this);
}
if (CODE_CONTAINS_STRUCT (code, TS_TYPED))
&& dump ("Read %stypedef %C:%N",
DECL_IMPLICIT_TYPEDEF_P (res) ? "implicit " : "",
TREE_CODE (res), res);
- res = TREE_TYPE (res);
+ if (TREE_CODE (res) != TU_LOCAL_ENTITY)
+ res = TREE_TYPE (res);
}
break;
--- /dev/null
+// PR c++/120412
+// { dg-additional-options "-fmodules -std=c++20 -Wtemplate-names-tu-local" }
+// { dg-module-cmi m:part }
+
+export module m:part;
+
+export template <typename F>
+auto fun1(F) {
+ return true;
+}
+
+using Dodgy = decltype([]{});
+
+export template <typename T>
+auto fun2(T&&) { // { dg-warning "TU-local" }
+ return fun1(Dodgy{});
+}
--- /dev/null
+// PR c++/120412
+// { dg-additional-options "-fmodules -std=c++20" }
+
+import m;
+
+int main() {
+ // { dg-error "instantiation exposes TU-local entity '(fun1|Dodgy)'" "" { target *-*-* } 0 }
+ fun2(123); // { dg-message "required from here" }
+}