diff --git a/include/clang/Basic/DiagnosticLexKinds.td b/include/clang/Basic/DiagnosticLexKinds.td index 8d6983122d..bd10642534 100644 --- a/include/clang/Basic/DiagnosticLexKinds.td +++ b/include/clang/Basic/DiagnosticLexKinds.td @@ -214,6 +214,10 @@ def ext_stdc_pragma_syntax : def ext_stdc_pragma_syntax_eom : ExtWarn<"expected end of macro in STDC pragma">, InGroup; +def warn_stdc_fenv_access_not_supported : + ExtWarn<"pragma STDC FENV_ACCESS ON is not supported, ignoring pragma">, + InGroup; + def err_pragma_comment_unknown_kind : Error<"unknown kind of pragma comment">; def err_defined_macro_name : Error<"'defined' cannot be used as a macro name">; def err_paste_at_start : Error< diff --git a/lib/Lex/Pragma.cpp b/lib/Lex/Pragma.cpp index d30ff3c289..0dc093fd74 100644 --- a/lib/Lex/Pragma.cpp +++ b/lib/Lex/Pragma.cpp @@ -560,7 +560,8 @@ struct PragmaSTDC_FP_CONTRACTHandler : public PragmaHandler { struct PragmaSTDC_FENV_ACCESSHandler : public PragmaHandler { PragmaSTDC_FENV_ACCESSHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {} virtual void HandlePragma(Preprocessor &PP, Token &Tok) { - LexOnOffSwitch(PP); + if (LexOnOffSwitch(PP) == STDC_ON) + PP.Diag(Tok, diag::warn_stdc_fenv_access_not_supported); } }; diff --git a/test/Preprocessor/pragma_unknown.c b/test/Preprocessor/pragma_unknown.c index d2738e5c7c..16bf43b3f4 100644 --- a/test/Preprocessor/pragma_unknown.c +++ b/test/Preprocessor/pragma_unknown.c @@ -10,7 +10,7 @@ #pragma STDC FP_CONTRACT DEFAULT #pragma STDC FP_CONTRACT IN_BETWEEN // expected-warning {{expected 'ON' or 'OFF' or 'DEFAULT' in pragma}} -#pragma STDC FENV_ACCESS ON +#pragma STDC FENV_ACCESS ON // expected-warning {{pragma STDC FENV_ACCESS ON is not supported, ignoring pragma}} #pragma STDC FENV_ACCESS OFF #pragma STDC FENV_ACCESS DEFAULT #pragma STDC FENV_ACCESS IN_BETWEEN // expected-warning {{expected 'ON' or 'OFF' or 'DEFAULT' in pragma}}