File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -666,6 +666,10 @@ Sema::resolveFunctionDecl(const FunctionDecl &function) {
666
666
if (!function.params .empty ())
667
667
return report (function.location ,
668
668
" 'main' function is expected to take no arguments" );
669
+ } else if (function.identifier == " printf" ) {
670
+ return report (function.location ,
671
+ " 'printf' is a reserved function name and cannot be used for "
672
+ " user-defined functions" );
669
673
}
670
674
671
675
std::vector<std::unique_ptr<ResolvedParamDecl>> resolvedParams;
Original file line number Diff line number Diff line change
1
+ // RUN: compiler %s -res-dump 2>&1 | filecheck %s
2
+
3
+ // CHECK: [[# @LINE + 1 ]]:1: error: 'printf' is a reserved function name and cannot be used for user-defined functions
4
+ fn printf(): number {
5
+ return 12345;
6
+ }
7
+
8
+ fn main(): void {
9
+ println(printf());
10
+ }
You can’t perform that action at this time.
0 commit comments