aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/parse/casting-operator2.C
blob: 008fa62dc74b78ad5868e5a3dc49b7ec556b23f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// { 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" }
}