2 Commits

Author SHA1 Message Date
erichkeane
380954b26f Fix test failure introduced in ab187bb
This patch, #147285 introduced a test that used
preserve_none/preserve_all/preserve_most for the purposes of validating
its ast-dump.  However, this attribute isn't supported on some
platforms, so this patch adds a triple to the test to ensure we try to
run it as a non-supported platform.

As this is simply an ast-dump test, there is no value to running it on
other configurations.
2025-07-09 06:18:49 -07:00
Andreas C. Osowski
ab187bbd3a
[clang][AST] Fix positioning of preserve cconv attributes in TypePrinter (#147285)
TypePrinter currently generates function pointer types that do not
compile when using the `preserve_.*` calling conventions as per
https://clang.llvm.org/docs/AttributeReference.html#preserve-all ff.

Running clang with `-Xclang -ast-print` on the following: 
```cc
using IN1 = void (__attribute__((preserve_most)) *)();
using IN2 = __attribute__((preserve_most)) void (*) ();
```

outputs:
```cc
using IN1 = void (*)() __attribute__((preserve_most));
using IN2 = void ((*))() __attribute__((preserve_most));
```

However, this does not compile:
```cc
<source>:3:23: error: expected ';' after alias declaration
    3 | using IN1 = void (*)() __attribute__((preserve_most));
```

This PR updates TypePrinter such that output is correct and compiles:
```cc
using IN1 = __attribute__((preserve_most)) void (*)();
using IN2 = __attribute__((preserve_most)) void ((*))();
```

I've verified via `-ast-dump` that the AST looks equivalent.
2025-07-09 08:52:56 -04:00