reject invalid stuff in the STDC namespace.

llvm-svn: 69551
This commit is contained in:
Chris Lattner 2009-04-19 21:25:37 +00:00
parent 958ee04368
commit a0b1f76d10
3 changed files with 14 additions and 10 deletions

View File

@ -206,6 +206,9 @@ def err_pragma_comment_malformed : Error<
"pragma comment requires parenthesized identifier and optional string">;
def warn_pragma_ignored : Warning<"unknown pragma ignored">,
InGroup<UnknownPragmas>, DefaultIgnore;
def ext_stdc_pragma_ignored : ExtWarn<"unknown pragma in STDC namespace">,
InGroup<UnknownPragmas>;
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">;

View File

@ -515,16 +515,16 @@ struct PragmaCommentHandler : public PragmaHandler {
/// PragmaSTDC_FP_CONTRACTHandler - "#pragma STDC FP_CONTRACT ...".
struct PragmaSTDC_FP_CONTRACTHandler : public PragmaHandler {
PragmaSTDC_FP_CONTRACTHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
virtual void HandlePragma(Preprocessor &PP, Token &CommentTok) {
//PP.HandlePragmaComment(CommentTok);
virtual void HandlePragma(Preprocessor &PP, Token &Tok) {
//PP.HandlePragmaFP_CONTRACT(CommentTok);
}
};
/// PragmaSTDC_FENV_ACCESSHandler - "#pragma STDC FENV_ACCESS ...".
struct PragmaSTDC_FENV_ACCESSHandler : public PragmaHandler {
PragmaSTDC_FENV_ACCESSHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
virtual void HandlePragma(Preprocessor &PP, Token &CommentTok) {
//PP.HandlePragmaComment(CommentTok);
virtual void HandlePragma(Preprocessor &PP, Token &Tok) {
//PP.HandlePragmaFENV_ACCESS(CommentTok);
}
};
@ -532,16 +532,16 @@ struct PragmaSTDC_FENV_ACCESSHandler : public PragmaHandler {
struct PragmaSTDC_CX_LIMITED_RANGEHandler : public PragmaHandler {
PragmaSTDC_CX_LIMITED_RANGEHandler(const IdentifierInfo *ID)
: PragmaHandler(ID) {}
virtual void HandlePragma(Preprocessor &PP, Token &CommentTok) {
//PP.HandlePragmaComment(CommentTok);
virtual void HandlePragma(Preprocessor &PP, Token &Tok) {
//PP.HandlePragmaCX_LIMITED_RANGE(CommentTok);
}
};
/// PragmaSTDC_UnknownHandler - "#pragma STDC ...".
struct PragmaSTDC_UnknownHandler : public PragmaHandler {
PragmaSTDC_UnknownHandler() : PragmaHandler(0) {}
virtual void HandlePragma(Preprocessor &PP, Token &CommentTok) {
//PP.HandlePragmaComment(CommentTok);
virtual void HandlePragma(Preprocessor &PP, Token &UnknownTok) {
PP.Diag(UnknownTok, diag::ext_stdc_pragma_ignored);
}
};

View File

@ -1,5 +1,5 @@
// RUN: clang-cc -E %s | grep '#pragma foo bar' &&
// RUN: clang-cc -fsyntax-only -Wunknown-pragmas %s
// RUN: clang-cc -fsyntax-only -Wunknown-pragmas -verify %s
// GCC doesn't expand macro args for unrecognized pragmas.
#define bar xX
@ -20,5 +20,6 @@
#pragma STDC CX_LIMITED_RANGE DEFAULT
#pragma STDC CX_LIMITED_RANGE IN_BETWEEN
#pragma STDC SO_GREAT
#pragma STDC SO_GREAT // expected-warning {{unknown pragma in STDC namespace}}
#pragma STDC // expected-warning {{unknown pragma in STDC namespace}}