/* Test all of the pragma directives from http://msdn.microsoft.com/en-us/library/d9x1s805(v=VS.10).aspx */ // Test __pragma keyword and macro expansion. // RUN: %clang_cc1 -fms-extensions -E %s -o - | FileCheck -check-prefix __PRAGMA %s // __PRAGMA: __pragma(warning(push)) // __PRAGMA: __pragma(warning(disable:6246)) // __PRAGMA: __pragma(warning(pop)) #define TEST___PRAGMA \ __pragma(warning(push)) \ __pragma(warning(disable:6246)) \ __pragma(warning(pop)) TEST___PRAGMA // alloc_text: Names the code section where the specified function definitions // are to reside. The pragma must occur between a function declarator and the // function definition for the named functions. // #pragma alloc_text( "textsection",function1, ... ) // // FIXME: I have no idea how to test this yet (coff_dump.py?). // see http://msdn.microsoft.com/en-us/library/sw8ty6zf.aspx for what should // happen extern "C" void function1(int *a); #pragma alloc_text("text_f1", function1) void function1(int *a) { ++(*a); }; // bss_seg: Specifies the segment where uninitialized variables are stored in // the .obj file. // #pragma bss_seg( [ [ { push | pop }, ] [ identifier, ] ] [ "segment-name" [, "segment-class" ] ) // // FIXME: I have no idea how to test this. // optimize: Specifies optimizations to be performed on a function-by-function // basis. // #pragma optimize( "[optimization-list]", {on | off} ) // // NOTE: I see no reason to impliment this. // pointers_to_members: Specifies whether a pointer to a class member can be // declared before its associated class definition and is used to control the // pointer size and the code required to interpret the pointer. // #pragma pointers_to_members(pointer-declaration, [most-general-representation] ) // // FIXME: I have no idea how to test this. // runtime_checks: Disables or restores the /RTC settings. // #pragma runtime_checks("[runtime_checks]", {restore | off} ) // // FIXME: I have no idea how to test this. // section: Creates a section in an .obj file. // #pragma section("section-name" [, attributes] ) // // SEE: http://msdn.microsoft.com/en-us/library/50bewfwa.aspx for attributes. // // FIXME: I have no idea how to test this (coff_dump.py?). #pragma section("mysec", read, write) int mysecj = 0; __declspec(allocate("mysec")) int myseci = 0; // setlocale: Defines the locale (Country/Region and language) to be used when // translating wide-character constants and string literals. // #pragma setlocale("[locale-string]") // // SEE: http://msdn.microsoft.com/en-us/library/39cwe7zf.aspx for a list of // valid language strings. // // FIXME: This test requires typing in a bunch of multi-byte string literals // with the L prefix (eg. L"Hello") in different languages (using chars from // each language). Then compile to an object file and look at the data to see // if the correct UCS-2 encoded string is there. #pragma setlocale("C") // strict_gs_check: This pragma provides enhanced security checking. // #pragma strict_gs_check([push,] { on | off } ) // #pragma strict_gs_check(pop) // // FIXME: I don't know how to test this. I do not think that Clang should // attempt to match MSVC exactly in this case, because it is not well defined, // and we can do better ;). This could be implimented using the runtime // undefined behaviour checks. #pragma strict_gs_check(push, on) void test_strict_gs_check() {} #pragma strict_gs_check(pop) // warning: Enables selective modification of the behavior of compiler warning // messages. // #pragma warning( warning-specifier : warning-number-list [; warning-specifier // : warning-number-list...] ) // #pragma warning( push[ ,n ] ) // #pragma warning( pop ) // // SEE: The following four links for a list of warnings. // http://msdn.microsoft.com/en-us/library/ysb0wexw(v=VS.100).aspx // http://msdn.microsoft.com/en-us/library/18kcz36b(v=VS.100).aspx // http://msdn.microsoft.com/en-us/library/t460hcc3(v=VS.100).aspx // http://msdn.microsoft.com/en-us/library/cfahxw6k(v=VS.100).aspx // // FIXME: There is no real way to test this becase MSVC and Clang use different // warning identifiers. To maintain compatibility with MSVC, clang may map // MSVC warnings to it's own when -fms-extensions is passed.