[cfe-commits] r69551 - in /cfe/trunk: include/clang/Basic/DiagnosticLexKinds.td lib/Lex/Pragma.cpp test/Preprocessor/pragma_unknown.c
Chris Lattner
sabre at nondot.org
Sun Apr 19 14:25:38 PDT 2009
Author: lattner
Date: Sun Apr 19 16:25:37 2009
New Revision: 69551
URL: http://llvm.org/viewvc/llvm-project?rev=69551&view=rev
Log:
reject invalid stuff in the STDC namespace.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/lib/Lex/Pragma.cpp
cfe/trunk/test/Preprocessor/pragma_unknown.c
Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=69551&r1=69550&r2=69551&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Sun Apr 19 16:25:37 2009
@@ -206,6 +206,9 @@
"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">;
Modified: cfe/trunk/lib/Lex/Pragma.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Pragma.cpp?rev=69551&r1=69550&r2=69551&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Pragma.cpp (original)
+++ cfe/trunk/lib/Lex/Pragma.cpp Sun Apr 19 16:25:37 2009
@@ -515,16 +515,16 @@
/// 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_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);
}
};
Modified: cfe/trunk/test/Preprocessor/pragma_unknown.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/pragma_unknown.c?rev=69551&r1=69550&r2=69551&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/pragma_unknown.c (original)
+++ cfe/trunk/test/Preprocessor/pragma_unknown.c Sun Apr 19 16:25:37 2009
@@ -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}}
More information about the cfe-commits
mailing list