diff options
-rw-r--r-- | gcc/cp/call.cc | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wclass-memaccess-2.C (renamed from gcc/testsuite/g++.dg/Wclass-memaccess-2.C) | 0 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wclass-memaccess-3.C (renamed from gcc/testsuite/g++.dg/Wclass-memaccess-3.C) | 0 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wclass-memaccess-4.C (renamed from gcc/testsuite/g++.dg/Wclass-memaccess-4.C) | 0 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wclass-memaccess-5.C (renamed from gcc/testsuite/g++.dg/Wclass-memaccess-5.C) | 0 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wclass-memaccess-6.C (renamed from gcc/testsuite/g++.dg/Wclass-memaccess-6.C) | 0 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wclass-memaccess-7.C | 13 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wclass-memaccess.C (renamed from gcc/testsuite/g++.dg/Wclass-memaccess.C) | 0 |
8 files changed, 15 insertions, 0 deletions
diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index 0240e36..14c6037 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -10329,6 +10329,8 @@ maybe_warn_class_memaccess (location_t loc, tree fndecl, /* Finally, warn on partial copies. */ unsigned HOST_WIDE_INT typesize = tree_to_uhwi (TYPE_SIZE_UNIT (desttype)); + if (typesize == 0) + break; if (unsigned HOST_WIDE_INT partial = tree_to_uhwi (sz) % typesize) warned = warning_at (loc, OPT_Wclass_memaccess, (typesize - partial > 1 diff --git a/gcc/testsuite/g++.dg/Wclass-memaccess-2.C b/gcc/testsuite/g++.dg/warn/Wclass-memaccess-2.C index f138b8b..f138b8b 100644 --- a/gcc/testsuite/g++.dg/Wclass-memaccess-2.C +++ b/gcc/testsuite/g++.dg/warn/Wclass-memaccess-2.C diff --git a/gcc/testsuite/g++.dg/Wclass-memaccess-3.C b/gcc/testsuite/g++.dg/warn/Wclass-memaccess-3.C index 36e0e68..36e0e68 100644 --- a/gcc/testsuite/g++.dg/Wclass-memaccess-3.C +++ b/gcc/testsuite/g++.dg/warn/Wclass-memaccess-3.C diff --git a/gcc/testsuite/g++.dg/Wclass-memaccess-4.C b/gcc/testsuite/g++.dg/warn/Wclass-memaccess-4.C index 69b8c78..69b8c78 100644 --- a/gcc/testsuite/g++.dg/Wclass-memaccess-4.C +++ b/gcc/testsuite/g++.dg/warn/Wclass-memaccess-4.C diff --git a/gcc/testsuite/g++.dg/Wclass-memaccess-5.C b/gcc/testsuite/g++.dg/warn/Wclass-memaccess-5.C index d0fffea..d0fffea 100644 --- a/gcc/testsuite/g++.dg/Wclass-memaccess-5.C +++ b/gcc/testsuite/g++.dg/warn/Wclass-memaccess-5.C diff --git a/gcc/testsuite/g++.dg/Wclass-memaccess-6.C b/gcc/testsuite/g++.dg/warn/Wclass-memaccess-6.C index 7f6fe03..7f6fe03 100644 --- a/gcc/testsuite/g++.dg/Wclass-memaccess-6.C +++ b/gcc/testsuite/g++.dg/warn/Wclass-memaccess-6.C diff --git a/gcc/testsuite/g++.dg/warn/Wclass-memaccess-7.C b/gcc/testsuite/g++.dg/warn/Wclass-memaccess-7.C new file mode 100644 index 0000000..7e86b24 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wclass-memaccess-7.C @@ -0,0 +1,13 @@ +// PR c++/105634 +// { dg-do compile { target { c++11 } } } +// { dg-options "-Wall" } + +struct s +{ + struct {} a[] = 1.0; // { dg-error "" } + void f (char *c) + { + s s; + __builtin_memcpy (&s, c, sizeof(s)); + } +}; diff --git a/gcc/testsuite/g++.dg/Wclass-memaccess.C b/gcc/testsuite/g++.dg/warn/Wclass-memaccess.C index 1dc23df..1dc23df 100644 --- a/gcc/testsuite/g++.dg/Wclass-memaccess.C +++ b/gcc/testsuite/g++.dg/warn/Wclass-memaccess.C |