From dcf67b297855acdc921de1687c9c1b28222e9931 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Thu, 12 Mar 2015 14:28:38 +0000 Subject: [PATCH] Use Sema's PrintingPolicy when diagnosing DeclSpecs. Sema overrides ASTContext's policy on the first emitted diagnostic (doesn't matter if it's ignored or not). This means changing the order of diagnostic emission in Sema suddenly changes the text of diagnostic emitted from the parser. In the test case -Wmissing-prototypes (ignored) was the culprit, use 'int main' to suppress that warning so we see when this regresses. Also move it into Sema/ as it's not testing any C++. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@232039 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Parse/ParseDecl.cpp | 3 ++- test/{SemaCXX => Sema}/pr9812.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) rename test/{SemaCXX => Sema}/pr9812.c (94%) diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index cea5824810..b4a7664298 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -2569,7 +2569,8 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, bool EnteringContext = (DSContext == DSC_class || DSContext == DSC_top_level); bool AttrsLastTime = false; ParsedAttributesWithRange attrs(AttrFactory); - const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy(); + // We use Sema's policy to get bool macros right. + const PrintingPolicy &Policy = Actions.getPrintingPolicy(); while (1) { bool isInvalid = false; bool isStorageClass = false; diff --git a/test/SemaCXX/pr9812.c b/test/Sema/pr9812.c similarity index 94% rename from test/SemaCXX/pr9812.c rename to test/Sema/pr9812.c index cbbe44ba7c..14bc6c810e 100644 --- a/test/SemaCXX/pr9812.c +++ b/test/Sema/pr9812.c @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s #define bool _Bool -int test1(int argc, char** argv) +int main(int argc, char** argv) { bool signed; // expected-error {{'bool' cannot be signed or unsigned}} expected-warning {{declaration does not declare anything}} -- 2.40.0