mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-13 12:31:16 +08:00
re PR c++/36695 (Value-initialization of reference type is allowed.)
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. From-SVN: r143244
This commit is contained in:
parent
56dbbf5621
commit
d67a3e2a7f
gcc
cp
testsuite
@ -1,3 +1,9 @@
|
||||
2009-01-10 Andrew Pinski <pinskia@gmail.com>
|
||||
|
||||
PR c++/36695
|
||||
* typeck2.c (build_functional_cast): Check for reference type and NULL
|
||||
PARMS.
|
||||
|
||||
2009-01-09 Steve Ellcey <sje@cup.hp.com>
|
||||
|
||||
* typeck.c (cp_build_unary_op): Check for ERROR_MARK.
|
||||
|
@ -1445,6 +1445,12 @@ build_functional_cast (tree exp, tree parms, tsubst_flags_t complain)
|
||||
else
|
||||
type = exp;
|
||||
|
||||
if (TREE_CODE (type) == REFERENCE_TYPE && !parms)
|
||||
{
|
||||
error ("invalid value-initialization of reference types");
|
||||
return error_mark_node;
|
||||
}
|
||||
|
||||
if (processing_template_decl)
|
||||
{
|
||||
tree t = build_min (CAST_EXPR, type, parms);
|
||||
|
@ -1,3 +1,12 @@
|
||||
2009-01-10 Andrew Pinski <pinskia@gmail.com>
|
||||
|
||||
PR c++/36695
|
||||
* 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.
|
||||
|
||||
2009-01-10 Paul Thomas <pault@gcc.gnu.org>
|
||||
|
||||
PR fortran/38763
|
||||
|
5
gcc/testsuite/g++.dg/ext/complex4.C
Normal file
5
gcc/testsuite/g++.dg/ext/complex4.C
Normal file
@ -0,0 +1,5 @@
|
||||
// { dg-do compile }
|
||||
// This code used to be rejected as there was no conversion from int to float __complex__
|
||||
#include <vector>
|
||||
typedef float __complex__ fcomplex;
|
||||
std::vector<fcomplex> vfc(10);
|
6
gcc/testsuite/g++.dg/ext/complex5.C
Normal file
6
gcc/testsuite/g++.dg/ext/complex5.C
Normal file
@ -0,0 +1,6 @@
|
||||
/* PR c++/21210 */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2" } */
|
||||
|
||||
typedef float __complex__ fcomplex;
|
||||
fcomplex cplx = fcomplex(0);
|
11
gcc/testsuite/g++.dg/init/reference1.C
Normal file
11
gcc/testsuite/g++.dg/init/reference1.C
Normal file
@ -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" }
|
||||
}
|
||||
|
13
gcc/testsuite/g++.dg/init/reference2.C
Normal file
13
gcc/testsuite/g++.dg/init/reference2.C
Normal file
@ -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" }
|
||||
}
|
||||
|
13
gcc/testsuite/g++.dg/init/reference3.C
Normal file
13
gcc/testsuite/g++.dg/init/reference3.C
Normal file
@ -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" }
|
||||
|
Loading…
x
Reference in New Issue
Block a user