Ivana Ivanovska
109e39c75c
Add support for nullptr literals in macros (#6426)
Adding support for macros that evaluate to nullptr literal.
Demo:
```c++
// macros.h
void foo(int a[2]);
#define MyNullPtr nullptr
```
```c++
// macros.cpp
void foo(int a[2]) {
if (!a) {
printf("array a is nullptr\n");
return;
}
printf("a[0] = %d \n", a[0]);
}
```
```c++
// main.carbon
library "Main";
import Cpp library "macros.h";
fn Run() -> i32 {
Cpp.foo(Cpp.MyNullPtr);
return 0;
}
```
```
$ clang -c macros.cpp;
$ bazel-bin/toolchain/carbon compile main.carbon
$ bazel-bin/toolchain/carbon link macros.o main.o \--output=demo_carbon
$ ./demo_carbon
array a is nullptr
```
Part of #6303
2025-11-24 21:03:35 +00:00
..
2025-11-24 21:03:35 +00:00
2025-02-20 22:42:47 +00:00
2025-11-24 21:03:35 +00:00
2025-10-30 22:50:59 +00:00
2025-04-11 21:47:43 +00:00
2025-11-12 17:06:39 +00:00
2025-11-11 20:30:19 +00:00
2025-09-29 14:26:23 +00:00
2025-01-27 23:48:44 +00:00
2025-11-13 17:54:49 +00:00
2025-09-29 16:05:06 +00:00
2025-11-06 08:45:28 +00:00
2025-09-29 16:05:06 +00:00
2025-09-18 13:04:18 +00:00
2025-07-11 22:29:10 +00:00
2025-11-11 20:30:19 +00:00
2025-11-11 20:30:19 +00:00
2025-07-10 21:21:19 +00:00
2025-07-10 16:32:39 +00:00
2025-11-20 00:09:10 +00:00
2025-11-14 13:50:56 +00:00
2025-04-23 15:20:18 +00:00
2025-05-07 22:20:39 +00:00
2025-05-07 22:20:39 +00:00
2025-10-28 17:17:38 +00:00
2025-06-03 18:07:23 +00:00
2025-06-10 22:09:31 +00:00
2025-06-10 22:09:31 +00:00
2025-08-12 22:08:07 +00:00
2025-07-21 20:02:27 +00:00
2025-09-10 13:47:59 +00:00
2025-11-05 21:36:42 +00:00
2025-11-13 20:17:44 +00:00
2025-11-14 13:50:56 +00:00
2025-11-21 22:28:08 +00:00
2025-04-14 14:28:15 +00:00
2025-11-21 22:28:08 +00:00
2025-10-28 17:17:38 +00:00
2025-03-04 21:01:59 +00:00
2025-08-21 21:41:53 +00:00
2025-06-10 22:09:31 +00:00
2025-05-01 20:24:15 +00:00
2025-05-01 20:24:15 +00:00
2025-10-28 17:17:38 +00:00
2025-10-22 18:26:32 +00:00
2025-03-18 23:49:24 +00:00
2024-07-03 17:49:47 +00:00
2025-10-28 17:17:38 +00:00
2025-04-28 19:06:24 +00:00
2025-11-18 19:48:58 +00:00
2025-11-11 20:30:19 +00:00
2025-11-07 16:25:27 +00:00
2025-09-29 16:05:06 +00:00
2025-04-23 19:03:53 +00:00
2025-04-28 19:06:24 +00:00
2025-05-09 16:35:28 +00:00
2024-07-12 22:38:06 +00:00
2025-11-14 00:40:26 +00:00
2025-04-23 19:03:53 +00:00
2025-02-14 19:44:36 +00:00
2025-11-11 14:16:09 +00:00
2025-11-05 17:21:41 +00:00
2025-09-29 18:17:48 +00:00
2025-11-11 16:36:15 +00:00
2025-11-11 20:30:19 +00:00
2025-09-16 20:45:01 +00:00
2025-06-25 23:45:14 +00:00
2024-07-12 22:38:06 +00:00
2025-04-23 15:20:18 +00:00
2025-11-05 17:21:41 +00:00
2025-11-11 16:36:15 +00:00
2025-04-28 19:06:24 +00:00
2024-12-18 00:19:12 +00:00
2025-11-09 18:17:09 +00:00
2024-07-12 22:38:06 +00:00
2025-09-02 23:15:26 +00:00
2025-11-21 22:28:08 +00:00
2024-07-12 22:38:06 +00:00
2025-11-18 00:28:06 +00:00
2025-04-10 20:53:42 +00:00
2025-08-12 16:27:07 +00:00
2025-06-10 22:09:31 +00:00
2025-11-18 00:28:06 +00:00
2025-10-20 17:25:26 +00:00
2025-10-20 18:44:05 +00:00
2025-05-22 18:58:47 +00:00
2025-11-18 00:28:06 +00:00
2025-07-25 18:34:07 +00:00
2025-11-20 23:07:04 +00:00
2025-09-10 21:40:27 +00:00
2025-11-13 18:34:13 +00:00
2025-11-13 18:34:13 +00:00
2025-03-21 23:09:37 +00:00
2025-11-11 16:36:15 +00:00
2025-11-13 18:34:13 +00:00
2025-11-13 18:34:13 +00:00
2025-11-21 22:28:08 +00:00
2025-10-30 20:47:16 +00:00
2025-09-12 22:59:37 +00:00
2025-11-14 13:50:56 +00:00
2025-07-09 22:42:27 +00:00
2025-08-29 01:11:24 +00:00
2025-08-29 01:11:24 +00:00
2025-10-30 22:50:59 +00:00
2025-09-26 23:18:16 +00:00
2025-11-18 19:48:58 +00:00
2025-10-22 18:26:32 +00:00
2025-04-28 19:06:24 +00:00
2024-10-17 22:47:40 +00:00
2025-03-18 00:31:17 +00:00
2025-01-22 23:15:00 +00:00
2025-11-12 23:23:48 +00:00
2025-11-12 23:23:48 +00:00
2025-06-10 20:54:58 +00:00
2025-06-10 20:54:58 +00:00
2025-06-10 22:09:31 +00:00
2025-06-10 22:09:31 +00:00
2025-02-07 22:35:18 +00:00
2025-11-14 13:50:56 +00:00
2025-11-11 20:30:19 +00:00
2025-02-26 18:44:36 +00:00
2025-02-25 02:07:43 +00:00
2025-11-18 19:48:58 +00:00
2025-01-23 02:21:48 +00:00
2025-11-13 17:04:58 +00:00
2025-11-13 17:04:58 +00:00
2025-09-15 23:59:00 +00:00
2025-05-01 22:17:55 +00:00
2025-05-01 22:17:55 +00:00
2025-04-14 14:28:15 +00:00
2025-09-12 00:13:33 +00:00
2025-05-01 22:17:55 +00:00
2025-11-14 13:50:56 +00:00
2025-05-07 22:20:39 +00:00
2025-09-25 21:56:48 +00:00
2025-11-18 00:28:06 +00:00
2025-10-28 17:17:38 +00:00
2025-11-18 19:48:58 +00:00
2025-06-11 21:34:01 +00:00
2025-11-21 22:28:08 +00:00
2025-10-31 22:10:35 +00:00
2025-10-10 12:37:37 +00:00
2025-09-30 20:15:55 +00:00
2025-11-08 00:45:12 +00:00
2025-11-08 00:45:12 +00:00