[cfe-commits] r112484 - in /cfe/trunk: include/clang/Basic/DiagnosticLexKinds.td lib/Lex/Pragma.cpp test/Preprocessor/pragma_diagnostic.c test/Preprocessor/pushable-diagnostics.c
Douglas Gregor
dgregor at apple.com
Mon Aug 30 08:15:34 PDT 2010
Author: dgregor
Date: Mon Aug 30 10:15:34 2010
New Revision: 112484
URL: http://llvm.org/viewvc/llvm-project?rev=112484&view=rev
Log:
Now that GCC will have #pragma push/pop (in GCC 4.6), allow the
#pragma without requiring it to be in the "clang" namespace, from
Louis Gerbarg!
Modified:
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/lib/Lex/Pragma.cpp
cfe/trunk/test/Preprocessor/pragma_diagnostic.c
cfe/trunk/test/Preprocessor/pushable-diagnostics.c
Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=112484&r1=112483&r2=112484&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Mon Aug 30 10:15:34 2010
@@ -252,15 +252,11 @@
def warn_stdc_fenv_access_not_supported :
Warning<"pragma STDC FENV_ACCESS ON is not supported, ignoring pragma">,
InGroup<UnknownPragmas>;
-def warn_pragma_diagnostic_gcc_invalid :
- ExtWarn<"pragma diagnostic expected 'error', 'warning', 'ignored', or"
- " 'fatal'">,
- InGroup<UnknownPragmas>;
-def warn_pragma_diagnostic_clang_invalid :
- ExtWarn<"pragma diagnostic expected 'error', 'warning', 'ignored', 'fatal'"
+def warn_pragma_diagnostic_invalid :
+ ExtWarn<"pragma diagnostic expected 'error', 'warning', 'ignored', 'fatal',"
" 'push', or 'pop'">,
InGroup<UnknownPragmas>;
-def warn_pragma_diagnostic_clang_cannot_ppp :
+def warn_pragma_diagnostic_cannot_pop :
ExtWarn<"pragma diagnostic pop could not pop, no matching push">,
InGroup<UnknownPragmas>;
def warn_pragma_diagnostic_invalid_option :
Modified: cfe/trunk/lib/Lex/Pragma.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Pragma.cpp?rev=112484&r1=112483&r2=112484&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Pragma.cpp (original)
+++ cfe/trunk/lib/Lex/Pragma.cpp Mon Aug 30 10:15:34 2010
@@ -747,7 +747,7 @@
Token Tok;
PP.LexUnexpandedToken(Tok);
if (Tok.isNot(tok::identifier)) {
- PP.Diag(Tok, diag::warn_pragma_diagnostic_clang_invalid);
+ PP.Diag(Tok, diag::warn_pragma_diagnostic_invalid);
return;
}
IdentifierInfo *II = Tok.getIdentifierInfo();
@@ -778,23 +778,14 @@
};
/// PragmaDiagnosticHandler - e.g. '#pragma GCC diagnostic ignored "-Wformat"'
-/// Since clang's diagnostic supports extended functionality beyond GCC's
-/// the constructor takes a clangMode flag to tell it whether or not to allow
-/// clang's extended functionality, or whether to reject it.
struct PragmaDiagnosticHandler : public PragmaHandler {
-private:
- const bool ClangMode;
public:
- explicit PragmaDiagnosticHandler(const bool clangMode)
- : PragmaHandler("diagnostic"), ClangMode(clangMode) {}
-
+ explicit PragmaDiagnosticHandler() : PragmaHandler("diagnostic") {}
virtual void HandlePragma(Preprocessor &PP, Token &DiagToken) {
Token Tok;
PP.LexUnexpandedToken(Tok);
if (Tok.isNot(tok::identifier)) {
- unsigned Diag = ClangMode ? diag::warn_pragma_diagnostic_clang_invalid
- : diag::warn_pragma_diagnostic_gcc_invalid;
- PP.Diag(Tok, Diag);
+ PP.Diag(Tok, diag::warn_pragma_diagnostic_invalid);
return;
}
IdentifierInfo *II = Tok.getIdentifierInfo();
@@ -808,22 +799,16 @@
Map = diag::MAP_IGNORE;
else if (II->isStr("fatal"))
Map = diag::MAP_FATAL;
- else if (ClangMode) {
- if (II->isStr("pop")) {
- if (!PP.getDiagnostics().popMappings())
- PP.Diag(Tok, diag::warn_pragma_diagnostic_clang_cannot_ppp);
- return;
- }
-
- if (II->isStr("push")) {
- PP.getDiagnostics().pushMappings();
- return;
- }
+ else if (II->isStr("pop")) {
+ if (!PP.getDiagnostics().popMappings())
+ PP.Diag(Tok, diag::warn_pragma_diagnostic_cannot_pop);
- PP.Diag(Tok, diag::warn_pragma_diagnostic_clang_invalid);
+ return;
+ } else if (II->isStr("push")) {
+ PP.getDiagnostics().pushMappings();
return;
} else {
- PP.Diag(Tok, diag::warn_pragma_diagnostic_gcc_invalid);
+ PP.Diag(Tok, diag::warn_pragma_diagnostic_invalid);
return;
}
@@ -855,9 +840,7 @@
if (Literal.hadError)
return;
if (Literal.Pascal) {
- unsigned Diag = ClangMode ? diag::warn_pragma_diagnostic_clang_invalid
- : diag::warn_pragma_diagnostic_gcc_invalid;
- PP.Diag(Tok, Diag);
+ PP.Diag(Tok, diag::warn_pragma_diagnostic_invalid);
return;
}
@@ -1001,13 +984,13 @@
AddPragmaHandler("GCC", new PragmaPoisonHandler());
AddPragmaHandler("GCC", new PragmaSystemHeaderHandler());
AddPragmaHandler("GCC", new PragmaDependencyHandler());
- AddPragmaHandler("GCC", new PragmaDiagnosticHandler(false));
+ AddPragmaHandler("GCC", new PragmaDiagnosticHandler());
// #pragma clang ...
AddPragmaHandler("clang", new PragmaPoisonHandler());
AddPragmaHandler("clang", new PragmaSystemHeaderHandler());
AddPragmaHandler("clang", new PragmaDebugHandler());
AddPragmaHandler("clang", new PragmaDependencyHandler());
- AddPragmaHandler("clang", new PragmaDiagnosticHandler(true));
+ AddPragmaHandler("clang", new PragmaDiagnosticHandler());
AddPragmaHandler("STDC", new PragmaSTDC_FP_CONTRACTHandler());
AddPragmaHandler("STDC", new PragmaSTDC_FENV_ACCESSHandler());
Modified: cfe/trunk/test/Preprocessor/pragma_diagnostic.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/pragma_diagnostic.c?rev=112484&r1=112483&r2=112484&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/pragma_diagnostic.c (original)
+++ cfe/trunk/test/Preprocessor/pragma_diagnostic.c Mon Aug 30 10:15:34 2010
@@ -20,9 +20,8 @@
#endif
-
#define foo error
-#pragma GCC diagnostic foo "-Wundef" // expected-warning {{pragma diagnostic expected 'error', 'warning', 'ignored', or 'fatal'}}
+#pragma GCC diagnostic foo "-Wundef" // expected-warning {{pragma diagnostic expected 'error', 'warning', 'ignored', 'fatal', 'push', or 'pop'}}
#pragma GCC diagnostic error 42 // expected-warning {{unexpected token in pragma diagnostic}}
Modified: cfe/trunk/test/Preprocessor/pushable-diagnostics.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/pushable-diagnostics.c?rev=112484&r1=112483&r2=112484&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/pushable-diagnostics.c (original)
+++ cfe/trunk/test/Preprocessor/pushable-diagnostics.c Mon Aug 30 10:15:34 2010
@@ -2,7 +2,7 @@
#pragma clang diagnostic pop // expected-warning{{pragma diagnostic pop could not pop, no matching push}}
-#pragma clang diagnostic puhs // expected-warning{{pragma diagnostic expected 'error', 'warning', 'ignored', 'fatal' 'push', or 'pop'}}
+#pragma clang diagnostic puhs // expected-warning {{pragma diagnostic expected 'error', 'warning', 'ignored', 'fatal', 'push', or 'pop'}}
char a = 'df'; // expected-warning{{multi-character character constant}}
More information about the cfe-commits
mailing list