29 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s2 3#pragma clang optimize off4 5#pragma clang optimize on6 7// Extra arguments8#pragma clang optimize on top of spaghetti // expected-error {{unexpected extra argument 'top' to '#pragma clang optimize'}}9 10// Wrong argument11#pragma clang optimize something_wrong // expected-error {{unexpected argument 'something_wrong' to '#pragma clang optimize'; expected 'on' or 'off'}}12 13// No argument14#pragma clang optimize // expected-error {{missing argument to '#pragma clang optimize'; expected 'on' or 'off'}}15 16// Check that macros can be used in the pragma17#define OFF off18#define ON on19#pragma clang optimize OFF20#pragma clang optimize ON21 22// Check that _Pragma can also be used to address the use case where users want23// to define optimization control macros to abstract out which compiler they are24// using.25#define OPT_OFF _Pragma("clang optimize off")26#define OPT_ON _Pragma("clang optimize on")27OPT_OFF28OPT_ON29