aboutsummaryrefslogtreecommitdiff
path: root/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp')
-rw-r--r--test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp93
1 files changed, 88 insertions, 5 deletions
diff --git a/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp b/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp
index f32b23976547..18b18834bb48 100644
--- a/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp
+++ b/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp
@@ -1,17 +1,25 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
struct X0 {
+ X0();
+ X0(int);
X0 f1();
X0 f2();
+ typedef int A;
+ typedef X0 B;
};
template<typename T>
-struct X1 {
+struct X1 : X0 {
+ X1();
X1<T>(int);
(X1<T>)(float);
X1 f2();
X1 f2(int);
X1 f2(float);
+ X1 f2(double);
+ X1 f2(short);
+ X1 f2(long);
};
// Error recovery: out-of-line constructors whose names have template arguments.
@@ -19,13 +27,88 @@ template<typename T> X1<T>::X1<T>(int) { } // expected-error{{out-of-line constr
template<typename T> (X1<T>::X1<T>)(float) { } // expected-error{{out-of-line constructor for 'X1' cannot have template arguments}}
// Error recovery: out-of-line constructor names intended to be types
-X0::X0 X0::f1() { return X0(); } // expected-error{{qualified reference to 'X0' is a constructor name rather than a type wherever a constructor can be declared}}
+X0::X0 X0::f1() { return X0(); } // expected-error{{qualified reference to 'X0' is a constructor name rather than a type in this context}}
struct X0::X0 X0::f2() { return X0(); }
-template<typename T> X1<T>::X1<T> X1<T>::f2() { } // expected-error{{qualified reference to 'X1' is a constructor name rather than a template name wherever a constructor can be declared}}
-template<typename T> X1<T>::X1<T> (X1<T>::f2)(int) { } // expected-error{{qualified reference to 'X1' is a constructor name rather than a template name wherever a constructor can be declared}}
+template<typename T> X1<T>::X1<T> X1<T>::f2() { } // expected-error{{missing 'typename'}}
+template<typename T> X1<T>::X1<T> (X1<T>::f2)(int) { } // expected-error{{missing 'typename'}}
template<typename T> struct X1<T>::X1<T> (X1<T>::f2)(float) { }
+template<typename T> struct X1<T>::X1 (X1<T>::f2)(double) { }
+template<typename T> typename X1<T>::template X1<T> X1<T>::f2(short) { } // expected-warning {{qualified reference to 'X1' is a constructor name rather than a template name in this context}}
+template<typename T> typename X1<T>::template X1<T> (X1<T>::f2)(long) { } // expected-warning {{qualified reference to 'X1' is a constructor name rather than a template name in this context}}
+
+void x1test(X1<int> x1i) {
+ x1i.f2();
+ x1i.f2(0);
+ x1i.f2(0.f);
+ x1i.f2(0.);
+}
+
+void other_contexts() {
+ X0::X0 x0; // expected-error{{qualified reference to 'X0' is a constructor name rather than a type in this context}}
+ X1<int>::X1 x1a; // expected-error{{qualified reference to 'X1' is a constructor name rather than a type in this context}}
+ X1<int>::X1<float> x1b; // expected-error{{qualified reference to 'X1' is a constructor name rather than a template name in this context}}
+
+ X0::B ok1;
+ X0::X0::A ok2;
+ X0::X0::X0 x0b; // expected-error{{qualified reference to 'X0' is a constructor name rather than a type in this context}}
+ X1<int>::X0 ok3;
+ X1<int>::X0::X0 x0c; // expected-error{{qualified reference to 'X0' is a constructor name rather than a type in this context}}
+ X1<int>::X1<float>::X0 ok4;
+
+ {
+ typename X0::X0 tn1; // expected-warning{{qualified reference to 'X0' is a constructor name rather than a type in this context}} expected-warning 0-1{{typename}}
+ typename X1<int>::X1<float> tn2; // expected-warning{{qualified reference to 'X1' is a constructor name rather than a template name in this context}} expected-warning 0-1{{typename}}
+ typename X0::B ok1; // expected-warning 0-1{{typename}}
+ typename X1<int>::X0 ok2; // expected-warning 0-1{{typename}}
+ }
+
+ {
+ struct X0::X0 tag1;
+ struct X1<int>::X1 tag2;
+ struct X1<int>::X1<int> tag3;
+ }
+
+ int a;
+ {
+ X0::X0(a); // expected-error{{qualified reference to 'X0' is a constructor name rather than a type in this context}}
+ }
+}
+
+template<typename T> void in_instantiation_x0() {
+ typename T::X0 x0; // expected-warning{{qualified reference to 'X0' is a constructor name rather than a type in this context}}
+ typename T::A a;
+ typename T::B b;
+}
+template void in_instantiation_x0<X0>(); // expected-note {{instantiation of}}
+
+template<typename T> void in_instantiation_x1() {
+ typename T::X1 x1; // expected-warning{{qualified reference to 'X1' is a constructor name rather than a type in this context}}
+ typename T::template X1<int> x1i; // expected-warning{{qualified reference to 'X1' is a constructor name rather than a template name in this context}}
+ typename T::X0 x0;
+}
+template void in_instantiation_x1<X1<int> >(); // expected-note {{instantiation of}}
+
+namespace sfinae {
+ template<typename T> void f(typename T::X0 *) = delete; // expected-warning 0-1{{extension}}
+ template<typename T> void f(...);
+ void g() { f<X0>(0); }
+}
+
+namespace versus_injected_class_name {
+ template <typename T> struct A : T::B {
+ struct T::B *p;
+ typename T::B::type a;
+ A() : T::B() {}
+
+ typename T::B b; // expected-warning {{qualified reference to 'B' is a constructor name rather than a type in this context}}
+ };
+ struct B {
+ typedef int type;
+ };
+ template struct A<B>; // expected-note {{in instantiation of}}
+}
// We have a special case for lookup within using-declarations that are
// member-declarations: foo::bar::baz::baz always names baz's constructor
@@ -109,7 +192,7 @@ namespace InhCtor {
// FIXME: Consider reusing the same diagnostic between dependent and non-dependent contexts
typedef int I;
struct UsingInt {
- using I::I; // expected-error {{'I' (aka 'int') is not a class, namespace, or enumeration}}
+ using I::I; // expected-error {{'InhCtor::I' (aka 'int') is not a class, namespace, or enumeration}}
};
template<typename T> struct UsingIntTemplate {
using T::T; // expected-error {{type 'int' cannot be used prior to '::' because it has no members}}