From 5f632cd204b7a85f3a97b6c316c5a34f9fc8193e Mon Sep 17 00:00:00 2001 From: Ronan Date: Fri, 25 Apr 2025 00:48:37 +0200 Subject: Implemented #pragma warning (#6748) * Implemented #pragma warning Based on https://learn.microsoft.com/en-us/cpp/preprocessor/warning?view=msvc-170 * Make #pragma warning work with #includes. - SourceLoc are not sorted by inclusion order. - Construct a mapping from SourceLoc to "absolute locations" that are sorted by inclusion order (roughly represents a location in a raw file with all #include resolved). - The absolute location can be used in the pragma warning timeline * Added preprocessor #pragma warning tests. - Fixed #pragma warning (push / pop) SourceLoc - Fixed unused directiveLoc in #pragma warning parsing * #pragma warning: Added some comments and fixed some typos * Cleaned #pragma warning preprocessor implementation. --------- Co-authored-by: Yong He --- tests/preprocessor/pragma-warning/defined-2.slang | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/preprocessor/pragma-warning/defined-2.slang (limited to 'tests/preprocessor/pragma-warning/defined-2.slang') diff --git a/tests/preprocessor/pragma-warning/defined-2.slang b/tests/preprocessor/pragma-warning/defined-2.slang new file mode 100644 index 000000000..7cde40a5a --- /dev/null +++ b/tests/preprocessor/pragma-warning/defined-2.slang @@ -0,0 +1,18 @@ +//TEST:SIMPLE(filecheck=CHECK): +// #ifdef support + +int64_t GetValue(); +#define SPECIFIER disable +#define IDs 30081 + +void f() +{ + int i; +#pragma warning (error : 30081) + // CHECK: ([[# @LINE+1]]): error 30081: + i = GetValue(); +#pragma warning (SPECIFIER : IDs) +} + +// Test that #pragma warning with #defined specifiers and IDs uses the correct SourceLoc +// (Use the macro invocation's SourceLoc, not the macro definition's SourceLoc) \ No newline at end of file -- cgit v1.2.3