Give the 'signed/unsigned wchar_t' extension a warning flag, and follow
authorRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 29 Jul 2019 20:00:46 +0000 (20:00 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 29 Jul 2019 20:00:46 +0000 (20:00 +0000)
GCC 9 in promoting it to an error by default.

llvm-svn: 367255

clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaType.cpp
clang/test/ASTMerge/exprs-cpp/test.cpp
clang/test/Misc/warning-flags.c
clang/test/SemaCXX/wchar_t.cpp

index 412bc7e..4cf1b34 100644 (file)
@@ -8509,10 +8509,11 @@ def warn_sync_fetch_and_nand_semantics_change : Warning<
   InGroup<DiagGroup<"sync-fetch-and-nand-semantics-changed">>;
 
 // Type
-def ext_invalid_sign_spec : Extension<"'%0' cannot be signed or unsigned">;
+def ext_wchar_t_sign_spec : ExtWarn<"'%0' cannot be signed or unsigned">,
+  InGroup<DiagGroup<"signed-unsigned-wchar">>, DefaultError;
 def warn_receiver_forward_class : Warning<
-    "receiver %0 is a forward class and corresponding @interface may not exist">,
-    InGroup<ForwardClassReceiver>;
+  "receiver %0 is a forward class and corresponding @interface may not exist">,
+  InGroup<ForwardClassReceiver>;
 def note_method_sent_forward_class : Note<"method %0 is used for the forward class">;
 def ext_missing_declspec : ExtWarn<
   "declaration specifier missing, defaulting to 'int'">;
index 62ff33a..00e2a0c 100644 (file)
@@ -1290,14 +1290,14 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
     if (DS.getTypeSpecSign() == DeclSpec::TSS_unspecified)
       Result = Context.WCharTy;
     else if (DS.getTypeSpecSign() == DeclSpec::TSS_signed) {
-      S.Diag(DS.getTypeSpecSignLoc(), diag::ext_invalid_sign_spec)
+      S.Diag(DS.getTypeSpecSignLoc(), diag::ext_wchar_t_sign_spec)
         << DS.getSpecifierName(DS.getTypeSpecType(),
                                Context.getPrintingPolicy());
       Result = Context.getSignedWCharType();
     } else {
       assert(DS.getTypeSpecSign() == DeclSpec::TSS_unsigned &&
         "Unknown TSS value");
-      S.Diag(DS.getTypeSpecSignLoc(), diag::ext_invalid_sign_spec)
+      S.Diag(DS.getTypeSpecSignLoc(), diag::ext_wchar_t_sign_spec)
         << DS.getSpecifierName(DS.getTypeSpecType(),
                                Context.getPrintingPolicy());
       Result = Context.getUnsignedWCharType();
index c0b282e..7bb6d17 100644 (file)
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -fcxx-exceptions -emit-pch -o %t.1.ast %S/Inputs/exprs3.cpp
-// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -fcxx-exceptions -ast-merge %t.1.ast -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -fcxx-exceptions -Wno-signed-unsigned-wchar -emit-pch -o %t.1.ast %S/Inputs/exprs3.cpp
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -fcxx-exceptions -Wno-signed-unsigned-wchar -ast-merge %t.1.ast -fsyntax-only -verify %s
 // expected-no-diagnostics
 
 static_assert(Ch1 == 'a');
index 81d332c..05172b2 100644 (file)
@@ -96,4 +96,4 @@ CHECK-NEXT:   warn_weak_import
 
 The list of warnings in -Wpedantic should NEVER grow.
 
-CHECK: Number in -Wpedantic (not covered by other -W flags): 28
+CHECK: Number in -Wpedantic (not covered by other -W flags): 27
index f9d7b61..f8e9add 100644 (file)
@@ -1,10 +1,12 @@
-// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s 
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-signed-unsigned-wchar -verify=allow-signed %s
+// allow-signed-no-diagnostics
 wchar_t x;
 
 void f(wchar_t p) {
   wchar_t x;
-  unsigned wchar_t y; // expected-warning {{'wchar_t' cannot be signed or unsigned}}
-  signed wchar_t z; // expected-warning {{'wchar_t' cannot be signed or unsigned}}
+  unsigned wchar_t y; // expected-error {{'wchar_t' cannot be signed or unsigned}}
+  signed wchar_t z; // expected-error {{'wchar_t' cannot be signed or unsigned}}
   ++x;
 }