From: Richard Smith Date: Mon, 29 Jul 2019 20:00:46 +0000 (+0000) Subject: Give the 'signed/unsigned wchar_t' extension a warning flag, and follow X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e5998ae05cf629deaa5e5c95d8fc692ddaca60ed;p=clang Give the 'signed/unsigned wchar_t' extension a warning flag, and follow GCC 9 in promoting it to an error by default. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@367255 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 412bc7e237..4cf1b3449d 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -8509,10 +8509,11 @@ def warn_sync_fetch_and_nand_semantics_change : Warning< InGroup>; // 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>, DefaultError; def warn_receiver_forward_class : Warning< - "receiver %0 is a forward class and corresponding @interface may not exist">, - InGroup; + "receiver %0 is a forward class and corresponding @interface may not exist">, + InGroup; 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'">; diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 62ff33ae7e..00e2a0cdc3 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -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(); diff --git a/test/ASTMerge/exprs-cpp/test.cpp b/test/ASTMerge/exprs-cpp/test.cpp index c0b282ec02..7bb6d17586 100644 --- a/test/ASTMerge/exprs-cpp/test.cpp +++ b/test/ASTMerge/exprs-cpp/test.cpp @@ -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'); diff --git a/test/Misc/warning-flags.c b/test/Misc/warning-flags.c index 81d332cacd..05172b2208 100644 --- a/test/Misc/warning-flags.c +++ b/test/Misc/warning-flags.c @@ -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 diff --git a/test/SemaCXX/wchar_t.cpp b/test/SemaCXX/wchar_t.cpp index f9d7b61432..f8e9addf27 100644 --- a/test/SemaCXX/wchar_t.cpp +++ b/test/SemaCXX/wchar_t.cpp @@ -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; }