diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-01-10 11:48:06 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-01-10 11:48:06 +0000 |
commit | 9d8ca5bfd418051156d14827bd03b99049fd3ae1 (patch) | |
tree | 36e36922fadb2cd823757e519e2f624ab5b76c8c /gcc/testsuite/g++.dg/init | |
parent | d27bb587265e060692f6f18ce43ef3166e9f764c (diff) | |
download | gcc-9d8ca5bfd418051156d14827bd03b99049fd3ae1.tar.gz |
PR c++/36695
* typeck2.c (build_functional_cast): Check for reference type and NULL
PARMS.
* g++.dg/ext/complex4.C: New test.
* g++.dg/ext/complex5.C: New test.
* g++.dg/init/reference1.C: New test.
* g++.dg/init/reference2.C: New test.
* g++.dg/init/reference3.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@143244 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/g++.dg/init')
-rw-r--r-- | gcc/testsuite/g++.dg/init/reference1.C | 11 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/init/reference2.C | 13 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/init/reference3.C | 13 |
3 files changed, 37 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/init/reference1.C b/gcc/testsuite/g++.dg/init/reference1.C new file mode 100644 index 00000000000..7ce5f90fb4c --- /dev/null +++ b/gcc/testsuite/g++.dg/init/reference1.C @@ -0,0 +1,11 @@ +// { dg-do compile } +// This code used to be accepted but it is invalid as there is no +// value initialization of a reference type. +// PR c++/36695 + +int main() +{ + typedef int& T; + T a = T(); // { dg-error "value-initialization of reference" } +} + diff --git a/gcc/testsuite/g++.dg/init/reference2.C b/gcc/testsuite/g++.dg/init/reference2.C new file mode 100644 index 00000000000..42f53742685 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/reference2.C @@ -0,0 +1,13 @@ +// { dg-do compile } +// This code used to be accepted but it is invalid as there is no +// value initialization of a reference type. +// PR c++/36695 + +// We should we able to diagnostic this without instantiating the template +template <int a1> +int f() +{ + typedef int& T; + T a = T(); // { dg-error "value-initialization of reference" } +} + diff --git a/gcc/testsuite/g++.dg/init/reference3.C b/gcc/testsuite/g++.dg/init/reference3.C new file mode 100644 index 00000000000..344e94e101e --- /dev/null +++ b/gcc/testsuite/g++.dg/init/reference3.C @@ -0,0 +1,13 @@ +// { dg-do compile } +// This code used to be accepted but it is invalid as there is no +// value initialization of a reference type. +// PR c++/36695 + +template <typename T> +T f() +{ + T a = T(); // { dg-error "value-initialization of reference" } +} + +int &a = f<int&>(); // { dg-message "instantiated from here" } + |