diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-07-29 20:00:46 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-07-29 20:00:46 +0000 |
commit | e8b659fc1ff02354438b1be0ff7016a12ec47603 (patch) | |
tree | 1a358437bff62ff17a5c8967da4d3144c9964078 /clang | |
parent | a625da716c8300d2ff9ec2313e7b38892bcfcfcb (diff) | |
download | bcm5719-llvm-e8b659fc1ff02354438b1be0ff7016a12ec47603.tar.gz bcm5719-llvm-e8b659fc1ff02354438b1be0ff7016a12ec47603.zip |
Give the 'signed/unsigned wchar_t' extension a warning flag, and follow
GCC 9 in promoting it to an error by default.
llvm-svn: 367255
Diffstat (limited to 'clang')
-rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 7 | ||||
-rw-r--r-- | clang/lib/Sema/SemaType.cpp | 4 | ||||
-rw-r--r-- | clang/test/ASTMerge/exprs-cpp/test.cpp | 4 | ||||
-rw-r--r-- | clang/test/Misc/warning-flags.c | 2 | ||||
-rw-r--r-- | clang/test/SemaCXX/wchar_t.cpp | 8 |
5 files changed, 14 insertions, 11 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 412bc7e2371..4cf1b3449d6 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -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'">; diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 62ff33ae7e2..00e2a0cdc3a 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/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/clang/test/ASTMerge/exprs-cpp/test.cpp b/clang/test/ASTMerge/exprs-cpp/test.cpp index c0b282ec028..7bb6d175869 100644 --- a/clang/test/ASTMerge/exprs-cpp/test.cpp +++ b/clang/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/clang/test/Misc/warning-flags.c b/clang/test/Misc/warning-flags.c index 81d332cacd4..05172b22085 100644 --- a/clang/test/Misc/warning-flags.c +++ b/clang/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/clang/test/SemaCXX/wchar_t.cpp b/clang/test/SemaCXX/wchar_t.cpp index f9d7b614329..f8e9addf27b 100644 --- a/clang/test/SemaCXX/wchar_t.cpp +++ b/clang/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; } |