aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-06-16 18:09:20 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-06-16 18:09:20 -0400
commitfa54bbb75d70055628f966d59570256649fa3fdb (patch)
tree402806f8ef758715dcce7e30d82a4bf585fabd0e /gcc
parent8787a05aaa4047eacd3d90ce8c1d9359747da4d2 (diff)
downloadgcc-fa54bbb75d70055628f966d59570256649fa3fdb.zip
gcc-fa54bbb75d70055628f966d59570256649fa3fdb.tar.gz
gcc-fa54bbb75d70055628f966d59570256649fa3fdb.tar.bz2
re PR c++/45378 ([C++0x] Narrowing error not detected)
PR c++/45378 * decl.c (check_initializer): Check narrowing. From-SVN: r175122
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/decl.c6
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/initlist52.C7
4 files changed, 18 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 000a781..3639302 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
2011-06-16 Jason Merrill <jason@redhat.com>
+ PR c++/45378
+ * decl.c (check_initializer): Check narrowing.
+
PR c++/49229
* pt.c (tsubst_decl) [FUNCTION_DECL]: Handle substitution failure.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 29edbe3..0584cd8 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -5464,7 +5464,11 @@ check_initializer (tree decl, tree init, int flags, tree *cleanup)
init = error_mark_node;
}
else
- init = reshape_init (type, init, tf_warning_or_error);
+ {
+ init = reshape_init (type, init, tf_warning_or_error);
+ if (cxx_dialect >= cxx0x && SCALAR_TYPE_P (type))
+ check_narrowing (type, init);
+ }
}
/* If DECL has an array type without a specific bound, deduce the
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 0da84e5..f8b82be 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2011-06-16 Jason Merrill <jason@redhat.com>
+ PR c++/45378
+ * g++.dg/cpp0x/initlist52.C New.
+
PR c++/45399
* c-c++-common/raw-string-12.c: New.
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist52.C b/gcc/testsuite/g++.dg/cpp0x/initlist52.C
new file mode 100644
index 0000000..22bc287
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist52.C
@@ -0,0 +1,7 @@
+// PR c++/45378
+// { dg-options -std=c++0x }
+
+int main()
+{
+ int x { 22.2 }; // { dg-error "narrowing" }
+}