r250099 - Parse and ignore #pragma runtime_checks in MS extensions mode (PR25138)
Hans Wennborg via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 12 13:47:58 PDT 2015
Author: hans
Date: Mon Oct 12 15:47:58 2015
New Revision: 250099
URL: http://llvm.org/viewvc/llvm-project?rev=250099&view=rev
Log:
Parse and ignore #pragma runtime_checks in MS extensions mode (PR25138)
We already silently ignore the /RTC, which controls the same functionality.
Modified:
cfe/trunk/include/clang/Lex/Pragma.h
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/Lex/Pragma.cpp
cfe/trunk/lib/Parse/ParsePragma.cpp
cfe/trunk/test/Preprocessor/pragma_microsoft.c
Modified: cfe/trunk/include/clang/Lex/Pragma.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Pragma.h?rev=250099&r1=250098&r2=250099&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Pragma.h (original)
+++ cfe/trunk/include/clang/Lex/Pragma.h Mon Oct 12 15:47:58 2015
@@ -76,7 +76,7 @@ public:
/// used to ignore particular pragmas.
class EmptyPragmaHandler : public PragmaHandler {
public:
- EmptyPragmaHandler();
+ explicit EmptyPragmaHandler(StringRef Name = StringRef());
void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
Token &FirstToken) override;
Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=250099&r1=250098&r2=250099&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Mon Oct 12 15:47:58 2015
@@ -163,6 +163,7 @@ class Parser : public CodeCompletionHand
std::unique_ptr<PragmaHandler> MSConstSeg;
std::unique_ptr<PragmaHandler> MSCodeSeg;
std::unique_ptr<PragmaHandler> MSSection;
+ std::unique_ptr<PragmaHandler> MSRuntimeChecks;
std::unique_ptr<PragmaHandler> OptimizeHandler;
std::unique_ptr<PragmaHandler> LoopHintHandler;
std::unique_ptr<PragmaHandler> UnrollHintHandler;
Modified: cfe/trunk/lib/Lex/Pragma.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Pragma.cpp?rev=250099&r1=250098&r2=250099&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Pragma.cpp (original)
+++ cfe/trunk/lib/Lex/Pragma.cpp Mon Oct 12 15:47:58 2015
@@ -38,7 +38,7 @@ PragmaHandler::~PragmaHandler() {
// EmptyPragmaHandler Implementation.
//===----------------------------------------------------------------------===//
-EmptyPragmaHandler::EmptyPragmaHandler() {}
+EmptyPragmaHandler::EmptyPragmaHandler(StringRef Name) : PragmaHandler(Name) {}
void EmptyPragmaHandler::HandlePragma(Preprocessor &PP,
PragmaIntroducerKind Introducer,
Modified: cfe/trunk/lib/Parse/ParsePragma.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParsePragma.cpp?rev=250099&r1=250098&r2=250099&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParsePragma.cpp (original)
+++ cfe/trunk/lib/Parse/ParsePragma.cpp Mon Oct 12 15:47:58 2015
@@ -156,6 +156,10 @@ struct PragmaUnrollHintHandler : public
Token &FirstToken) override;
};
+struct PragmaMSRuntimeChecksHandler : public EmptyPragmaHandler {
+ PragmaMSRuntimeChecksHandler() : EmptyPragmaHandler("runtime_checks") {}
+};
+
} // end namespace
void Parser::initializePragmaHandlers() {
@@ -222,6 +226,8 @@ void Parser::initializePragmaHandlers()
PP.AddPragmaHandler(MSCodeSeg.get());
MSSection.reset(new PragmaMSPragma("section"));
PP.AddPragmaHandler(MSSection.get());
+ MSRuntimeChecks.reset(new PragmaMSRuntimeChecksHandler());
+ PP.AddPragmaHandler(MSRuntimeChecks.get());
}
OptimizeHandler.reset(new PragmaOptimizeHandler(Actions));
@@ -288,6 +294,8 @@ void Parser::resetPragmaHandlers() {
MSCodeSeg.reset();
PP.RemovePragmaHandler(MSSection.get());
MSSection.reset();
+ PP.RemovePragmaHandler(MSRuntimeChecks.get());
+ MSRuntimeChecks.reset();
}
PP.RemovePragmaHandler("STDC", FPContractHandler.get());
Modified: cfe/trunk/test/Preprocessor/pragma_microsoft.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/pragma_microsoft.c?rev=250099&r1=250098&r2=250099&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/pragma_microsoft.c (original)
+++ cfe/trunk/test/Preprocessor/pragma_microsoft.c Mon Oct 12 15:47:58 2015
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-extensions
+// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-extensions -Wunknown-pragmas
// RUN: not %clang_cc1 %s -fms-extensions -E | FileCheck %s
// REQUIRES: non-ps4-sdk
@@ -53,7 +53,7 @@ __pragma(comment(linker," bar=" BAR))
void f()
{
- __pragma()
+ __pragma() // expected-warning{{unknown pragma ignored}}
// CHECK: #pragma
// If we ever actually *support* __pragma(warning(disable: x)),
@@ -159,3 +159,6 @@ void g() {}
#pragma warning(default 321) // expected-warning {{expected ':'}}
#pragma warning(asdf : 321) // expected-warning {{expected 'push', 'pop'}}
#pragma warning(push, -1) // expected-warning {{requires a level between 0 and 4}}
+
+// Test that runtime_checks is parsed but ignored.
+#pragma runtime_checks("sc", restore) // no-warning
More information about the cfe-commits
mailing list