Commit cc8c7495 by Giovanni Bajo

re PR c++/8856 (g++ accepts invalid conversion-function-id)

	PR c++/8856
	* g++.dg/parse/casting-operator2.C: New test.
	* g++.old-deja/g++.pt/explicit83.C: Remove.

From-SVN: r75898
parent 0d956474
2004-01-15 Giovanni Bajo <giovannibajo@gcc.gnu.org>
PR c++/8856
* g++.dg/parse/casting-operator2.C: New test.
* g++.old-deja/g++.pt/explicit83.C: Remove.
2004-01-14 Joseph S. Myers <jsm@polyomino.org.uk> 2004-01-14 Joseph S. Myers <jsm@polyomino.org.uk>
* gcc.dg/label-compound-stmt-1.c: New test. * gcc.dg/label-compound-stmt-1.c: New test.
......
// { dg-do compile }
// Contributed by Martin Loewis <loewis at informatik dot hu-berlin dot de>
// PR c++/8856: Make sure template conversion operators are not parsed as
// template names.
struct K {};
template <bool> struct K2 {};
template <class T> struct A {
template <class U> operator U() { return U(); }
};
int main() {
A<double> a;
(void)a.operator int();
(void)a.operator double();
(void)a.operator K2<true>();
(void)a.A<double>::operator int();
(void)a.A<double>::operator double();
(void)a.A<double>::operator K2<true>();
(void)a.operator double<int>(); // { dg-error "not a template" }
(void)a.operator K<int>(); // { dg-error "not a template" }
(void)a.A<double>::operator double<int>(); // { dg-error "not a template" }
(void)a.A<double>::operator K<int>(); // { dg-error "not a template" }
}
// { dg-do assemble }
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 7 Sep 2000 <nathan@codesourcery.com>
// Bug 512. Conversion operator functions in template_id's were always
// being looked up in global scope.
class C
{
public:
template <typename T>
void f () {}
template<typename T>
operator int ()
{ return 0;
}
};
template void C::f <int>();
template C::operator int<float> ();
template C::operator int<double> ();
typedef int (C::* ptrmem_t) ();
template<ptrmem_t U, ptrmem_t V>
void foo ()
{
}
template void
foo<&C::operator int<float>, &C::operator int<double> > ();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment