r232039 - Use Sema's PrintingPolicy when diagnosing DeclSpecs.

Benjamin Kramer benny.kra at googlemail.com
Thu Mar 12 07:28:39 PDT 2015


Author: d0k
Date: Thu Mar 12 09:28:38 2015
New Revision: 232039

URL: http://llvm.org/viewvc/llvm-project?rev=232039&view=rev
Log:
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++.

Added:
    cfe/trunk/test/Sema/pr9812.c
      - copied, changed from r232038, cfe/trunk/test/SemaCXX/pr9812.c
Removed:
    cfe/trunk/test/SemaCXX/pr9812.c
Modified:
    cfe/trunk/lib/Parse/ParseDecl.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=232039&r1=232038&r2=232039&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Thu Mar 12 09:28:38 2015
@@ -2569,7 +2569,8 @@ void Parser::ParseDeclarationSpecifiers(
   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;

Copied: cfe/trunk/test/Sema/pr9812.c (from r232038, cfe/trunk/test/SemaCXX/pr9812.c)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/pr9812.c?p2=cfe/trunk/test/Sema/pr9812.c&p1=cfe/trunk/test/SemaCXX/pr9812.c&r1=232038&r2=232039&rev=232039&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/pr9812.c (original)
+++ cfe/trunk/test/Sema/pr9812.c Thu Mar 12 09:28:38 2015
@@ -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}}
 

Removed: cfe/trunk/test/SemaCXX/pr9812.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/pr9812.c?rev=232038&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/pr9812.c (original)
+++ cfe/trunk/test/SemaCXX/pr9812.c (removed)
@@ -1,21 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-
-#define bool _Bool
-int test1(int argc, char** argv)
-{
-    bool signed;  // expected-error {{'bool' cannot be signed or unsigned}} expected-warning {{declaration does not declare anything}}
-
-    return 0;
-}
-#undef bool
-
-typedef int bool;
-
-int test2(int argc, char** argv)
-{
-    bool signed; // expected-error {{'type-name' cannot be signed or unsigned}} expected-warning {{declaration does not declare anything}}
-    _Bool signed; // expected-error {{'_Bool' cannot be signed or unsigned}} expected-warning {{declaration does not declare anything}}
-
-    return 0;
-}
-





More information about the cfe-commits mailing list