[clang] [clang][Lex] Fix crash on pragma annotations (PR #238342)

Pranjal Srivastava via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 3 10:46:00 PST 2026


================
@@ -256,3 +256,17 @@ void pragma_optimize_foo() {
 #pragma execution_character_set(push, "utf-8")
 #pragma execution_character_set(push, "UTF-8")
 #pragma execution_character_set(pop)
+
+#define PRAGMA_PACK _Pragma("pack(push, 1)")
+#pragma warning(PRAGMA_PACK) // expected-warning {{expected 'push', 'pop', 'default', 'disable', 'error', 'once', 'suppress', 1, 2, 3, or 4}} \
+                             // expected-error {{expected identifier or '('}}
+;
+#pragma warning(disable : 4705 ; PRAGMA_PACK) // expected-warning {{expected 'push', 'pop', 'default', 'disable', 'error', 'once', 'suppress', 1, 2, 3, or 4}} \
+                                              // expected-error {{expected identifier or '('}}
+;
+#pragma execution_character_set(PRAGMA_PACK) // expected-warning {{expected 'push' or 'pop'}} \
----------------
ipranjalks wrote:

Done, switched to `expected-error at -n` instead of line-continuation backslashes. Thanks!

https://github.com/llvm/llvm-project/pull/238342


More information about the cfe-commits mailing list