summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorRachel Craik <rcraik@ca.ibm.com>2015-09-14 21:27:36 +0000
committerRachel Craik <rcraik@ca.ibm.com>2015-09-14 21:27:36 +0000
commit022bdc7d7361f48a359194e630e8b16f1d134cfe (patch)
treec5fb8cc07ba6e991599a0a92d16763d95f673d83 /clang/test
parentbace032eb81aa9bf2bad513a693291243d03c6a7 (diff)
downloadbcm5719-llvm-022bdc7d7361f48a359194e630e8b16f1d134cfe.tar.gz
bcm5719-llvm-022bdc7d7361f48a359194e630e8b16f1d134cfe.zip
C11 _Bool bitfield diagnostic
Summary: Implement DR262 (for C). This patch will mainly affect bitfields of type _Bool Reviewers: fraggamuffin, rsmith Subscribers: hubert.reinterpretcast, cfe-commits Differential Revision: http://reviews.llvm.org/D10018 llvm-svn: 247618
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CodeGen/bitfield-2.c2
-rw-r--r--clang/test/CodeGenCXX/warn-padded-packed.cpp2
-rw-r--r--clang/test/Misc/warning-flags.c4
-rw-r--r--clang/test/Sema/bitfield.c7
-rw-r--r--clang/test/SemaCXX/bitfield-layout.cpp8
-rw-r--r--clang/test/SemaCXX/constant-expression-cxx11.cpp6
-rw-r--r--clang/test/SemaCXX/constant-expression-cxx1y.cpp2
-rw-r--r--clang/test/SemaCXX/ms_wide_bitfield.cpp7
-rw-r--r--clang/test/SemaObjC/class-bitfield.m2
9 files changed, 21 insertions, 19 deletions
diff --git a/clang/test/CodeGen/bitfield-2.c b/clang/test/CodeGen/bitfield-2.c
index e4b1b0d9fd5..9d669575ecd 100644
--- a/clang/test/CodeGen/bitfield-2.c
+++ b/clang/test/CodeGen/bitfield-2.c
@@ -237,7 +237,7 @@ unsigned long long test_5() {
/***/
struct s6 {
- _Bool f0 : 2;
+ unsigned f0 : 2;
};
struct s6 g6 = { 0xF };
diff --git a/clang/test/CodeGenCXX/warn-padded-packed.cpp b/clang/test/CodeGenCXX/warn-padded-packed.cpp
index 4203bb3dda1..f15373e5b5e 100644
--- a/clang/test/CodeGenCXX/warn-padded-packed.cpp
+++ b/clang/test/CodeGenCXX/warn-padded-packed.cpp
@@ -69,7 +69,7 @@ struct S12 {
struct S13 { // expected-warning {{padding size of 'S13' with 6 bits to alignment boundary}}
char c;
- bool b : 10; // expected-warning {{size of bit-field 'b' (10 bits) exceeds the size of its type}}
+ bool b : 10; // expected-warning {{width of bit-field 'b' (10 bits) exceeds the width of its type}}
};
// The warnings are emitted when the layout of the structs is computed, so we have to use them.
diff --git a/clang/test/Misc/warning-flags.c b/clang/test/Misc/warning-flags.c
index 92cb9a0ad6c..f61e966612b 100644
--- a/clang/test/Misc/warning-flags.c
+++ b/clang/test/Misc/warning-flags.c
@@ -18,7 +18,7 @@ This test serves two purposes:
The list of warnings below should NEVER grow. It should gradually shrink to 0.
-CHECK: Warnings without flags (92):
+CHECK: Warnings without flags (90):
CHECK-NEXT: ext_excess_initializers
CHECK-NEXT: ext_excess_initializers_in_char_array_initializer
CHECK-NEXT: ext_expected_semi_decl_list
@@ -44,10 +44,8 @@ CHECK-NEXT: pp_pragma_once_in_main_file
CHECK-NEXT: pp_pragma_sysheader_in_main_file
CHECK-NEXT: w_asm_qualifier_ignored
CHECK-NEXT: warn_accessor_property_type_mismatch
-CHECK-NEXT: warn_anon_bitfield_width_exceeds_type_size
CHECK-NEXT: warn_arcmt_nsalloc_realloc
CHECK-NEXT: warn_asm_label_on_auto_decl
-CHECK-NEXT: warn_bitfield_width_exceeds_type_size
CHECK-NEXT: warn_c_kext
CHECK-NEXT: warn_call_to_pure_virtual_member_function_from_ctor_dtor
CHECK-NEXT: warn_call_wrong_number_of_arguments
diff --git a/clang/test/Sema/bitfield.c b/clang/test/Sema/bitfield.c
index f214b671f6f..ba8460d3f6c 100644
--- a/clang/test/Sema/bitfield.c
+++ b/clang/test/Sema/bitfield.c
@@ -6,7 +6,7 @@ struct a {
int a : -1; // expected-error{{bit-field 'a' has negative width}}
// rdar://6081627
- int b : 33; // expected-error{{size of bit-field 'b' (33 bits) exceeds size of its type (32 bits)}}
+ int b : 33; // expected-error{{width of bit-field 'b' (33 bits) exceeds width of its type (32 bits)}}
int c : (1 + 0.25); // expected-error{{expression is not an integer constant expression}}
int d : (int)(1 + 0.25);
@@ -22,9 +22,12 @@ struct a {
int g : (_Bool)1;
// PR4017
- char : 10; // expected-error {{size of anonymous bit-field (10 bits) exceeds size of its type (8 bits)}}
+ char : 10; // expected-error {{width of anonymous bit-field (10 bits) exceeds width of its type (8 bits)}}
unsigned : -2; // expected-error {{anonymous bit-field has negative width (-2)}}
float : 12; // expected-error {{anonymous bit-field has non-integral type 'float'}}
+
+ _Bool : 2; // expected-error {{width of anonymous bit-field (2 bits) exceeds width of its type (1 bit)}}
+ _Bool h : 5; // expected-error {{width of bit-field 'h' (5 bits) exceeds width of its type (1 bit)}}
};
struct b {unsigned x : 2;} x;
diff --git a/clang/test/SemaCXX/bitfield-layout.cpp b/clang/test/SemaCXX/bitfield-layout.cpp
index adecf55a877..25aa8222992 100644
--- a/clang/test/SemaCXX/bitfield-layout.cpp
+++ b/clang/test/SemaCXX/bitfield-layout.cpp
@@ -5,25 +5,25 @@
// Simple tests.
struct Test1 {
- char c : 9; // expected-warning {{size of bit-field 'c' (9 bits) exceeds the size of its type; value will be truncated to 8 bits}}
+ char c : 9; // expected-warning {{width of bit-field 'c' (9 bits) exceeds the width of its type; value will be truncated to 8 bits}}
};
CHECK_SIZE(Test1, 2);
CHECK_ALIGN(Test1, 1);
struct Test2 {
- char c : 16; // expected-warning {{size of bit-field 'c' (16 bits) exceeds the size of its type; value will be truncated to 8 bits}}
+ char c : 16; // expected-warning {{width of bit-field 'c' (16 bits) exceeds the width of its type; value will be truncated to 8 bits}}
};
CHECK_SIZE(Test2, 2);
CHECK_ALIGN(Test2, 2);
struct Test3 {
- char c : 32; // expected-warning {{size of bit-field 'c' (32 bits) exceeds the size of its type; value will be truncated to 8 bits}}
+ char c : 32; // expected-warning {{width of bit-field 'c' (32 bits) exceeds the width of its type; value will be truncated to 8 bits}}
};
CHECK_SIZE(Test3, 4);
CHECK_ALIGN(Test3, 4);
struct Test4 {
- char c : 64; // expected-warning {{size of bit-field 'c' (64 bits) exceeds the size of its type; value will be truncated to 8 bits}}
+ char c : 64; // expected-warning {{width of bit-field 'c' (64 bits) exceeds the width of its type; value will be truncated to 8 bits}}
};
CHECK_SIZE(Test4, 8);
CHECK_ALIGN(Test4, 8);
diff --git a/clang/test/SemaCXX/constant-expression-cxx11.cpp b/clang/test/SemaCXX/constant-expression-cxx11.cpp
index 67c0f8700db..ead69faa918 100644
--- a/clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ b/clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -1801,9 +1801,9 @@ namespace Bitfields {
bool b : 1;
unsigned u : 5;
int n : 5;
- bool b2 : 3;
- unsigned u2 : 74; // expected-warning {{exceeds the size of its type}}
- int n2 : 81; // expected-warning {{exceeds the size of its type}}
+ bool b2 : 3; // expected-warning {{exceeds the width of its type}}
+ unsigned u2 : 74; // expected-warning {{exceeds the width of its type}}
+ int n2 : 81; // expected-warning {{exceeds the width of its type}}
};
constexpr A a = { false, 33, 31, false, 0xffffffff, 0x7fffffff }; // expected-warning 2{{truncation}}
diff --git a/clang/test/SemaCXX/constant-expression-cxx1y.cpp b/clang/test/SemaCXX/constant-expression-cxx1y.cpp
index e8925f3f84a..a3444533ce8 100644
--- a/clang/test/SemaCXX/constant-expression-cxx1y.cpp
+++ b/clang/test/SemaCXX/constant-expression-cxx1y.cpp
@@ -872,7 +872,7 @@ namespace Lifetime {
namespace Bitfields {
struct A {
- bool b : 3;
+ bool b : 1;
int n : 4;
unsigned u : 5;
};
diff --git a/clang/test/SemaCXX/ms_wide_bitfield.cpp b/clang/test/SemaCXX/ms_wide_bitfield.cpp
index d917390ef14..2b11579a5cd 100644
--- a/clang/test/SemaCXX/ms_wide_bitfield.cpp
+++ b/clang/test/SemaCXX/ms_wide_bitfield.cpp
@@ -1,9 +1,10 @@
// RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple i686-pc-win32 -fdump-record-layouts -fsyntax-only -mms-bitfields -verify %s 2>&1
struct A {
- char a : 9; // expected-error{{size of bit-field 'a' (9 bits) exceeds size of its type (8 bits)}}
- int b : 33; // expected-error{{size of bit-field 'b' (33 bits) exceeds size of its type (32 bits)}}
- bool c : 9; // expected-error{{size of bit-field 'c' (9 bits) exceeds size of its type (8 bits)}}
+ char a : 9; // expected-error{{width of bit-field 'a' (9 bits) exceeds width of its type (8 bits)}}
+ int b : 33; // expected-error{{width of bit-field 'b' (33 bits) exceeds width of its type (32 bits)}}
+ bool c : 9; // expected-error{{width of bit-field 'c' (9 bits) exceeds width of its type (1 bit)}}
+ bool d : 3; // expected-error{{width of bit-field 'd' (3 bits) exceeds width of its type (1 bit)}}
};
int a[sizeof(A) == 1 ? 1 : -1];
diff --git a/clang/test/SemaObjC/class-bitfield.m b/clang/test/SemaObjC/class-bitfield.m
index 4b13d9a2569..a225d1157f5 100644
--- a/clang/test/SemaObjC/class-bitfield.m
+++ b/clang/test/SemaObjC/class-bitfield.m
@@ -5,7 +5,7 @@
int a : -1; // expected-error{{bit-field 'a' has negative width}}
// rdar://6081627
- int b : 33; // expected-error{{size of bit-field 'b' (33 bits) exceeds size of its type (32 bits)}}
+ int b : 33; // expected-error{{width of bit-field 'b' (33 bits) exceeds width of its type (32 bits)}}
int c : (1 + 0.25); // expected-error{{expression is not an integer constant expression}}
int d : (int)(1 + 0.25);
OpenPOWER on IntegriCloud