mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 19:01:05 +01:00
Add framework for the extern keyword. (#3755)
This doesn't add full support. I'm separating it out to make the effects of the modifier changes clearer for review. I'm restructuring a little with the expectation that we'll have some more categories of modifier keywords in the future (similar to `extern`, these may not be in a "set" such as access), and thus easily scaling up to a few more would be useful.
This commit is contained in:
@@ -70,6 +70,17 @@ base fn InvalidModifier();
|
||||
// CHECK:STDERR: ^~~~~~~
|
||||
default final virtual fn ModifiersConflict2() {}
|
||||
|
||||
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+9]]:1: ERROR: `extern` not allowed on `fn` declaration.
|
||||
// CHECK:STDERR: extern private fn ExternOrderAndConflict() {}
|
||||
// CHECK:STDERR: ^~~~~~
|
||||
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+6]]:8: ERROR: `private` must appear before `extern`.
|
||||
// CHECK:STDERR: extern private fn ExternOrderAndConflict() {}
|
||||
// CHECK:STDERR: ^~~~~~~
|
||||
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+3]]:1: `extern` previously appeared here.
|
||||
// CHECK:STDERR: extern private fn ExternOrderAndConflict() {}
|
||||
// CHECK:STDERR: ^~~~~~
|
||||
extern private fn ExternOrderAndConflict() {}
|
||||
|
||||
// CHECK:STDOUT: --- fail_modifiers.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
@@ -80,6 +91,7 @@ default final virtual fn ModifiersConflict2() {}
|
||||
// CHECK:STDOUT: .ModifiersConflict = %ModifiersConflict
|
||||
// CHECK:STDOUT: .InvalidModifier = %InvalidModifier
|
||||
// CHECK:STDOUT: .ModifiersConflict2 = %ModifiersConflict2
|
||||
// CHECK:STDOUT: .ExternOrderAndConflict = %ExternOrderAndConflict
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %WrongOrder: <function> = fn_decl @WrongOrder [template] {}
|
||||
// CHECK:STDOUT: %DuplicateVirtual: <function> = fn_decl @DuplicateVirtual [template] {}
|
||||
@@ -87,6 +99,7 @@ default final virtual fn ModifiersConflict2() {}
|
||||
// CHECK:STDOUT: %ModifiersConflict: <function> = fn_decl @ModifiersConflict [template] {}
|
||||
// CHECK:STDOUT: %InvalidModifier: <function> = fn_decl @InvalidModifier [template] {}
|
||||
// CHECK:STDOUT: %ModifiersConflict2: <function> = fn_decl @ModifiersConflict2 [template] {}
|
||||
// CHECK:STDOUT: %ExternOrderAndConflict: <function> = fn_decl @ExternOrderAndConflict [template] {}
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @WrongOrder();
|
||||
@@ -110,3 +123,8 @@ default final virtual fn ModifiersConflict2() {}
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @ExternOrderAndConflict() {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
|
||||
Reference in New Issue
Block a user