mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-30 09:25:26 +01:00
Following #1191, add initial support for bitwise operators. Support for both integer operations and for operator overloading via the interfaces specified in #1191 is provided. Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
25 lines
712 B
Plaintext
25 lines
712 B
Plaintext
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
// RUN: %{explorer} %s 2>&1 | \
|
|
// RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes=false %s
|
|
// RUN: %{explorer} --parser_debug --trace_file=- %s 2>&1 | \
|
|
// RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes %s
|
|
// AUTOUPDATE: %{explorer} %s
|
|
// CHECK: result: -6
|
|
|
|
package ExplorerTest api;
|
|
|
|
class A { var n: i32; }
|
|
|
|
external impl A as BitComplement where .Result == A {
|
|
fn Op[me: Self]() -> A { return {.n = ^me.n}; }
|
|
}
|
|
|
|
fn Main() -> i32 {
|
|
var a: A = {.n = 5};
|
|
a = ^a;
|
|
return a.n;
|
|
}
|