aboutsummaryrefslogtreecommitdiff
path: root/test/CXX/dcl.decl
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2014-11-24 09:15:30 +0000
committerDimitry Andric <dim@FreeBSD.org>2014-11-24 09:15:30 +0000
commit9f4dbff6669c8037f3b036bcf580d14f1a4f12a5 (patch)
tree47df2c12b57214af6c31e47404b005675b8b7ffc /test/CXX/dcl.decl
parentf73d5f23a889b93d89ddef61ac0995df40286bb8 (diff)
downloadsrc-9f4dbff6669c8037f3b036bcf580d14f1a4f12a5.tar.gz
src-9f4dbff6669c8037f3b036bcf580d14f1a4f12a5.zip
Vendor import of clang RELEASE_350/final tag r216957 (effectively, 3.5.0 release):vendor/clang/clang-release_350-r216957
Notes
Notes: svn path=/vendor/clang/dist/; revision=274958 svn path=/vendor/clang/clang-release_350-r216957/; revision=274959; tag=vendor/clang/clang-release_350-r216957
Diffstat (limited to 'test/CXX/dcl.decl')
-rw-r--r--test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp4
-rw-r--r--test/CXX/dcl.decl/dcl.init/dcl.init.list/p3-0x.cpp16
-rw-r--r--test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp2
-rw-r--r--test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp105
-rw-r--r--test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp91
-rw-r--r--test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp15
-rw-r--r--test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp13
-rw-r--r--test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp6
-rw-r--r--test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p3.cpp2
-rw-r--r--test/CXX/dcl.decl/dcl.meaning/dcl.ref/p6-0x.cpp5
-rw-r--r--test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp80
-rw-r--r--test/CXX/dcl.decl/dcl.meaning/p1.cpp18
12 files changed, 233 insertions, 124 deletions
diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp
index b30e0ec7856b..b44b2c7d1566 100644
--- a/test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp
+++ b/test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp
@@ -8,9 +8,9 @@ namespace PR12453 {
template<typename T>
void f(int i) {
T x{i}; // expected-error{{non-constant-expression cannot be narrowed from type 'int' to 'float' in initializer list}} \
- // expected-note{{override this message by inserting an explicit cast}}
+ // expected-note{{insert an explicit cast to silence this issue}}
T y{i}; // expected-error{{non-constant-expression cannot be narrowed from type 'int' to 'float' in initializer list}} \
- // expected-note{{override this message by inserting an explicit cast}}
+ // expected-note{{insert an explicit cast to silence this issue}}
}
template void f<float>(int); // expected-note{{in instantiation of function template specialization 'PR12453::f<float>' requested here}}
diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3-0x.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3-0x.cpp
index 58d038366c81..971e0c11aff1 100644
--- a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3-0x.cpp
+++ b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3-0x.cpp
@@ -23,7 +23,7 @@ namespace std {
namespace bullet1 {
double ad[] = { 1, 2.0 };
- int ai[] = { 1, 2.0 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{override}}
+ int ai[] = { 1, 2.0 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{silence}}
struct S2 {
int m1;
@@ -31,7 +31,7 @@ namespace bullet1 {
};
S2 s21 = { 1, 2, 3.0 };
- S2 s22 { 1.0, 2, 3 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{override}}
+ S2 s22 { 1.0, 2, 3 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{silence}}
S2 s23 { };
}
@@ -62,13 +62,13 @@ namespace bullet4_example3 {
};
S s1 = { 1, 2, 3.0 };
- S s2 { 1.0, 2, 3 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{override}}
+ S s2 { 1.0, 2, 3 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{silence}}
S s3 {};
}
namespace bullet5 {
int x1 {2};
- int x2 {2.0}; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{override}}
+ int x2 {2.0}; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{silence}}
}
namespace bullet6 {
@@ -81,7 +81,7 @@ namespace bullet6 {
const S& r2 = { "Spinach" };
S& r3 = { 1, 2, 3 }; // expected-error {{non-const lvalue reference to type 'bullet6::S' cannot bind to an initializer list temporary}}
const int& i1 = { 1 };
- const int& i2 = { 1.1 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{override}} expected-warning {{implicit conversion}}
+ const int& i2 = { 1.1 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{silence}} expected-warning {{implicit conversion}}
const int (&iar)[2] = { 1, 2 };
}
@@ -92,20 +92,20 @@ namespace bullet7 {
namespace bullet8 {
struct A { int i; int j; };
A a1 { 1, 2 };
- A a2 { 1.2 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{override}} expected-warning {{implicit conversion}}
+ A a2 { 1.2 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{silence}} expected-warning {{implicit conversion}}
struct B {
B(std::initializer_list<int> i) {}
};
B b1 { 1, 2 };
- B b2 { 1, 2.0 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{override}}
+ B b2 { 1, 2.0 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{silence}}
struct C {
C(int i, double j) {}
};
C c1 = { 1, 2.2 };
// FIXME: Suppress the narrowing warning in the cases where we issue a narrowing error.
- C c2 = { 1.1, 2 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{override}} expected-warning {{implicit conversion}}
+ C c2 = { 1.1, 2 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{silence}} expected-warning {{implicit conversion}}
int j { 1 };
int k { };
diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp
index 0bea4ede19ca..299611ba7359 100644
--- a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp
+++ b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp
@@ -26,7 +26,7 @@ void test_template() {
maybe_shrink_int((char)3);
// CHECK: warning:{{.*}} cannot be narrowed
// CHECK: note:{{.*}} in instantiation
- // CHECK: note:{{.*}} override
+ // CHECK: note:{{.*}} silence
// FIXME: This should be static_cast<T>.
// CHECK: fix-it:{{.*}}"static_cast<char>("
// CHECK: fix-it:{{.*}}")"
diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
index 9b1727fd04af..42dee92b3ca3 100644
--- a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
+++ b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
@@ -8,16 +8,16 @@ void std_example() {
const int y = 999;
const int z = 99;
char c1 = x; // OK, though it might narrow (in this case, it does narrow)
- char c2{x}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
- char c3{y}; // expected-error {{ cannot be narrowed }} expected-note {{override}} expected-warning {{changes value}}
+ char c2{x}; // expected-error {{ cannot be narrowed }} expected-note {{silence}}
+ char c3{y}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} expected-warning {{changes value}}
char c4{z}; // OK: no narrowing needed
unsigned char uc1 = {5}; // OK: no narrowing needed
- unsigned char uc2 = {-1}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
- unsigned int ui1 = {-1}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ unsigned char uc2 = {-1}; // expected-error {{ cannot be narrowed }} expected-note {{silence}}
+ unsigned int ui1 = {-1}; // expected-error {{ cannot be narrowed }} expected-note {{silence}}
signed int si1 =
- { (unsigned int)-1 }; // expected-error {{ cannot be narrowed }} expected-note {{override}}
- int ii = {2.0}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
- float f1 { x }; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ { (unsigned int)-1 }; // expected-error {{ cannot be narrowed }} expected-note {{silence}}
+ int ii = {2.0}; // expected-error {{ cannot be narrowed }} expected-note {{silence}}
+ float f1 { x }; // expected-error {{ cannot be narrowed }} expected-note {{silence}}
float f2 { 7 }; // OK: 7 can be exactly represented as a float
int f(int);
int a[] =
@@ -44,19 +44,19 @@ template<typename T> Convert<T> ConvertVar();
// * from a floating-point type to an integer type, or
void float_to_int() {
- Agg<char> a1 = {1.0F}; // expected-error {{type 'float' cannot be narrowed to 'char'}} expected-note {{override}}
- Agg<char> a2 = {1.0}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
- Agg<char> a3 = {1.0L}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ Agg<char> a1 = {1.0F}; // expected-error {{type 'float' cannot be narrowed to 'char'}} expected-note {{silence}}
+ Agg<char> a2 = {1.0}; // expected-error {{ cannot be narrowed }} expected-note {{silence}}
+ Agg<char> a3 = {1.0L}; // expected-error {{ cannot be narrowed }} expected-note {{silence}}
float f = 1.0;
double d = 1.0;
long double ld = 1.0;
- Agg<char> a4 = {f}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
- Agg<char> a5 = {d}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
- Agg<char> a6 = {ld}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ Agg<char> a4 = {f}; // expected-error {{ cannot be narrowed }} expected-note {{silence}}
+ Agg<char> a5 = {d}; // expected-error {{ cannot be narrowed }} expected-note {{silence}}
+ Agg<char> a6 = {ld}; // expected-error {{ cannot be narrowed }} expected-note {{silence}}
- Agg<char> ce1 = { Convert<float>(1.0) }; // expected-error {{type 'float' cannot be narrowed to 'char'}} expected-note {{override}}
- Agg<char> ce2 = { ConvertVar<double>() }; // expected-error {{type 'double' cannot be narrowed to 'char'}} expected-note {{override}}
+ Agg<char> ce1 = { Convert<float>(1.0) }; // expected-error {{type 'float' cannot be narrowed to 'char'}} expected-note {{silence}}
+ Agg<char> ce2 = { ConvertVar<double>() }; // expected-error {{type 'double' cannot be narrowed to 'char'}} expected-note {{silence}}
}
// * from long double to double or float, or from double to float, except where
@@ -72,8 +72,8 @@ void shrink_float() {
// Variables.
Agg<float> f1 = {f}; // OK (no-op)
- Agg<float> f2 = {d}; // expected-error {{non-constant-expression cannot be narrowed from type 'double' to 'float'}} expected-note {{override}}
- Agg<float> f3 = {ld}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ Agg<float> f2 = {d}; // expected-error {{non-constant-expression cannot be narrowed from type 'double' to 'float'}} expected-note {{silence}}
+ Agg<float> f3 = {ld}; // expected-error {{ cannot be narrowed }} expected-note {{silence}}
// Exact constants.
Agg<float> f4 = {1.0}; // OK (double constant represented exactly)
Agg<float> f5 = {1.0L}; // OK (long double constant represented exactly)
@@ -81,8 +81,8 @@ void shrink_float() {
Agg<float> f6 = {0.1}; // OK (double constant in range but rounded)
Agg<float> f7 = {0.1L}; // OK (long double constant in range but rounded)
// Out of range constants.
- Agg<float> f8 = {1E50}; // expected-error {{constant expression evaluates to 1.000000e+50 which cannot be narrowed to type 'float'}} expected-note {{override}}
- Agg<float> f9 = {1E50L}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ Agg<float> f8 = {1E50}; // expected-error {{constant expression evaluates to 1.000000e+50 which cannot be narrowed to type 'float'}} expected-note {{silence}}
+ Agg<float> f9 = {1E50L}; // expected-error {{ cannot be narrowed }} expected-note {{silence}}
// More complex constant expression.
constexpr long double e40 = 1E40L, e30 = 1E30L, e39 = 1E39L;
Agg<float> f10 = {e40 - 5 * e39 + e30 - 5 * e39}; // OK
@@ -90,19 +90,19 @@ void shrink_float() {
// Variables.
Agg<double> d1 = {f}; // OK (widening)
Agg<double> d2 = {d}; // OK (no-op)
- Agg<double> d3 = {ld}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ Agg<double> d3 = {ld}; // expected-error {{ cannot be narrowed }} expected-note {{silence}}
// Exact constant.
Agg<double> d4 = {1.0L}; // OK (long double constant represented exactly)
// Inexact but in-range constant.
Agg<double> d5 = {0.1L}; // OK (long double constant in range but rounded)
// Out of range constant.
- Agg<double> d6 = {1E315L}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ Agg<double> d6 = {1E315L}; // expected-error {{ cannot be narrowed }} expected-note {{silence}}
// More complex constant expression.
constexpr long double e315 = 1E315L, e305 = 1E305L, e314 = 1E314L;
Agg<double> d7 = {e315 - 5 * e314 + e305 - 5 * e314}; // OK
- Agg<float> ce1 = { Convert<double>(1e300) }; // expected-error {{constant expression evaluates to 1.000000e+300 which cannot be narrowed to type 'float'}} expected-note {{override}}
- Agg<double> ce2 = { ConvertVar<long double>() }; // expected-error {{non-constant-expression cannot be narrowed from type 'long double' to 'double'}} expected-note {{override}}
+ Agg<float> ce1 = { Convert<double>(1e300) }; // expected-error {{constant expression evaluates to 1.000000e+300 which cannot be narrowed to type 'float'}} expected-note {{silence}}
+ Agg<double> ce2 = { ConvertVar<long double>() }; // expected-error {{non-constant-expression cannot be narrowed from type 'long double' to 'double'}} expected-note {{silence}}
}
// * from an integer type or unscoped enumeration type to a floating-point type,
@@ -114,16 +114,16 @@ void int_to_float() {
char c = 1;
// Variables. Yes, even though all char's will fit into any floating type.
- Agg<float> f1 = {c}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
- Agg<double> f2 = {c}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
- Agg<long double> f3 = {c}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ Agg<float> f1 = {c}; // expected-error {{ cannot be narrowed }} expected-note {{silence}}
+ Agg<double> f2 = {c}; // expected-error {{ cannot be narrowed }} expected-note {{silence}}
+ Agg<long double> f3 = {c}; // expected-error {{ cannot be narrowed }} expected-note {{silence}}
// Constants.
Agg<float> f4 = {12345678}; // OK (exactly fits in a float)
- Agg<float> f5 = {123456789}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ Agg<float> f5 = {123456789}; // expected-error {{ cannot be narrowed }} expected-note {{silence}}
- Agg<float> ce1 = { Convert<int>(123456789) }; // expected-error {{constant expression evaluates to 123456789 which cannot be narrowed to type 'float'}} expected-note {{override}}
- Agg<double> ce2 = { ConvertVar<long long>() }; // expected-error {{non-constant-expression cannot be narrowed from type 'long long' to 'double'}} expected-note {{override}}
+ Agg<float> ce1 = { Convert<int>(123456789) }; // expected-error {{constant expression evaluates to 123456789 which cannot be narrowed to type 'float'}} expected-note {{silence}}
+ Agg<double> ce2 = { ConvertVar<long long>() }; // expected-error {{non-constant-expression cannot be narrowed from type 'long long' to 'double'}} expected-note {{silence}}
}
// * from an integer type or unscoped enumeration type to an integer type that
@@ -135,52 +135,53 @@ void shrink_int() {
// Not a constant expression.
short s = 1;
unsigned short us = 1;
- Agg<char> c1 = {s}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
- Agg<unsigned short> s1 = {s}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
- Agg<short> s2 = {us}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ Agg<char> c1 = {s}; // expected-error {{ cannot be narrowed }} expected-note {{silence}}
+ Agg<unsigned short> s1 = {s}; // expected-error {{ cannot be narrowed }} expected-note {{silence}}
+ Agg<short> s2 = {us}; // expected-error {{ cannot be narrowed }} expected-note {{silence}}
// "that cannot represent all the values of the original type" means that the
// validity of the program depends on the relative sizes of integral types.
// This test compiles with -m64, so sizeof(int)<sizeof(long)==sizeof(long
// long).
long l1 = 1;
- Agg<int> i1 = {l1}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ Agg<int> i1 = {l1}; // expected-error {{ cannot be narrowed }} expected-note {{silence}}
long long ll = 1;
Agg<long> l2 = {ll}; // OK
// Constants.
Agg<char> c2 = {127}; // OK
- Agg<char> c3 = {300}; // expected-error {{ cannot be narrowed }} expected-note {{override}} expected-warning {{changes value}}
+ Agg<char> c3 = {300}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} expected-warning {{changes value}}
Agg<int> i2 = {0x7FFFFFFFU}; // OK
- Agg<int> i3 = {0x80000000U}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
- Agg<unsigned int> i4 = {-0x80000000L}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ Agg<int> i3 = {0x80000000U}; // expected-error {{ cannot be narrowed }} expected-note {{silence}}
+ Agg<unsigned int> i4 = {-0x80000000L}; // expected-error {{ cannot be narrowed }} expected-note {{silence}}
// Bool is also an integer type, but conversions to it are a different AST
// node.
Agg<bool> b1 = {0}; // OK
Agg<bool> b2 = {1}; // OK
- Agg<bool> b3 = {-1}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ Agg<bool> b3 = {-1}; // expected-error {{ cannot be narrowed }} expected-note {{silence}}
// Conversions from pointers to booleans aren't narrowing conversions.
- Agg<bool> b = {&b1}; // OK
+ Agg<bool>* ptr = &b1;
+ Agg<bool> b = {ptr}; // OK
- Agg<short> ce1 = { Convert<int>(100000) }; // expected-error {{constant expression evaluates to 100000 which cannot be narrowed to type 'short'}} expected-note {{override}} expected-warning {{changes value from 100000 to -31072}}
- Agg<char> ce2 = { ConvertVar<short>() }; // expected-error {{non-constant-expression cannot be narrowed from type 'short' to 'char'}} expected-note {{override}}
+ Agg<short> ce1 = { Convert<int>(100000) }; // expected-error {{constant expression evaluates to 100000 which cannot be narrowed to type 'short'}} expected-note {{silence}} expected-warning {{changes value from 100000 to -31072}}
+ Agg<char> ce2 = { ConvertVar<short>() }; // expected-error {{non-constant-expression cannot be narrowed from type 'short' to 'char'}} expected-note {{silence}}
// Negative -> larger unsigned type.
- unsigned long long ll1 = { -1 }; // expected-error {{ -1 which cannot be narrowed}} expected-note {{override}}
+ unsigned long long ll1 = { -1 }; // expected-error {{ -1 which cannot be narrowed}} expected-note {{silence}}
unsigned long long ll2 = { 1 }; // OK
- unsigned long long ll3 = { s }; // expected-error {{cannot be narrowed from type 'short'}} expected-note {{override}}
+ unsigned long long ll3 = { s }; // expected-error {{cannot be narrowed from type 'short'}} expected-note {{silence}}
unsigned long long ll4 = { us }; // OK
- unsigned long long ll5 = { ll }; // expected-error {{cannot be narrowed from type 'long long'}} expected-note {{override}}
- Agg<unsigned long long> ll6 = { -1 }; // expected-error {{ -1 which cannot be narrowed}} expected-note {{override}}
+ unsigned long long ll5 = { ll }; // expected-error {{cannot be narrowed from type 'long long'}} expected-note {{silence}}
+ Agg<unsigned long long> ll6 = { -1 }; // expected-error {{ -1 which cannot be narrowed}} expected-note {{silence}}
Agg<unsigned long long> ll7 = { 18446744073709551615ULL }; // OK
- Agg<unsigned long long> ll8 = { __int128(18446744073709551615ULL) + 1 }; // expected-error {{ 18446744073709551616 which cannot be narrowed}} expected-note {{override}} expected-warning {{changes value}}
+ Agg<unsigned long long> ll8 = { __int128(18446744073709551615ULL) + 1 }; // expected-error {{ 18446744073709551616 which cannot be narrowed}} expected-note {{silence}} expected-warning {{changes value}}
signed char c = 'x';
- unsigned short usc1 = { c }; // expected-error {{non-constant-expression cannot be narrowed from type 'signed char'}} expected-note {{override}}
+ unsigned short usc1 = { c }; // expected-error {{non-constant-expression cannot be narrowed from type 'signed char'}} expected-note {{silence}}
unsigned short usc2 = { (signed char)'x' }; // OK
- unsigned short usc3 = { (signed char)-1 }; // expected-error {{ -1 which cannot be narrowed}} expected-note {{override}}
+ unsigned short usc3 = { (signed char)-1 }; // expected-error {{ -1 which cannot be narrowed}} expected-note {{silence}}
}
// Be sure that type- and value-dependent expressions in templates get the error
@@ -188,9 +189,9 @@ void shrink_int() {
template<int I, typename T>
void maybe_shrink_int(T t) {
- Agg<short> s1 = {t}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
- Agg<short> s2 = {I}; // expected-error {{ cannot be narrowed }} expected-note {{override}} expected-warning {{changes value}}
- Agg<T> t2 = {700}; // expected-error {{ cannot be narrowed }} expected-note {{override}} expected-warning {{changes value}}
+ Agg<short> s1 = {t}; // expected-error {{ cannot be narrowed }} expected-note {{silence}}
+ Agg<short> s2 = {I}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} expected-warning {{changes value}}
+ Agg<T> t2 = {700}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} expected-warning {{changes value}}
}
void test_template() {
@@ -203,9 +204,9 @@ void test_template() {
void test_qualifiers(int i) {
const int j = i;
- struct {const unsigned char c;} c1 = {j}; // expected-error {{from type 'int' to 'unsigned char' in}} expected-note {{override}}
+ struct {const unsigned char c;} c1 = {j}; // expected-error {{from type 'int' to 'unsigned char' in}} expected-note {{silence}}
// Template arguments make it harder to avoid printing qualifiers:
- Agg<const unsigned char> c2 = {j}; // expected-error {{from type 'int' to 'const unsigned char' in}} expected-note {{override}}
+ Agg<const unsigned char> c2 = {j}; // expected-error {{from type 'int' to 'const unsigned char' in}} expected-note {{silence}}
}
// Test SFINAE checks.
diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp
index 4bcf113d7142..d4d8198d4fc8 100644
--- a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp
+++ b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp
@@ -9,16 +9,16 @@ void std_example() {
const int y = 999;
const int z = 99;
char c1 = x; // OK, though it might narrow (in this case, it does narrow)
- char c2{x}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
- char c3{y}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} expected-warning {{changes value}}
+ char c2{x}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
+ char c3{y}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} expected-warning {{changes value}}
char c4{z}; // OK: no narrowing needed
unsigned char uc1 = {5}; // OK: no narrowing needed
- unsigned char uc2 = {-1}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
- unsigned int ui1 = {-1}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ unsigned char uc2 = {-1}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
+ unsigned int ui1 = {-1}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
signed int si1 =
- { (unsigned int)-1 }; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
- int ii = {2.0}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
- float f1 { x }; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ { (unsigned int)-1 }; // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
+ int ii = {2.0}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
+ float f1 { x }; // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
float f2 { 7 }; // OK: 7 can be exactly represented as a float
int f(int);
int a[] =
@@ -45,19 +45,19 @@ template<typename T> Convert<T> ConvertVar();
// * from a floating-point type to an integer type, or
void float_to_int() {
- Agg<char> a1 = {1.0F}; // expected-warning {{type 'float' cannot be narrowed to 'char'}} expected-note {{override}}
- Agg<char> a2 = {1.0}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
- Agg<char> a3 = {1.0L}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<char> a1 = {1.0F}; // expected-warning {{type 'float' cannot be narrowed to 'char'}} expected-note {{silence}}
+ Agg<char> a2 = {1.0}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
+ Agg<char> a3 = {1.0L}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
float f = 1.0;
double d = 1.0;
long double ld = 1.0;
- Agg<char> a4 = {f}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
- Agg<char> a5 = {d}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
- Agg<char> a6 = {ld}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<char> a4 = {f}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
+ Agg<char> a5 = {d}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
+ Agg<char> a6 = {ld}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
- Agg<char> ce1 = { Convert<float>(1.0) }; // expected-warning {{type 'float' cannot be narrowed to 'char'}} expected-note {{override}}
- Agg<char> ce2 = { ConvertVar<double>() }; // expected-warning {{type 'double' cannot be narrowed to 'char'}} expected-note {{override}}
+ Agg<char> ce1 = { Convert<float>(1.0) }; // expected-warning {{type 'float' cannot be narrowed to 'char'}} expected-note {{silence}}
+ Agg<char> ce2 = { ConvertVar<double>() }; // expected-warning {{type 'double' cannot be narrowed to 'char'}} expected-note {{silence}}
}
// * from long double to double or float, or from double to float, except where
@@ -73,8 +73,8 @@ void shrink_float() {
// Variables.
Agg<float> f1 = {f}; // OK (no-op)
- Agg<float> f2 = {d}; // expected-warning {{non-constant-expression cannot be narrowed from type 'double' to 'float'}} expected-note {{override}}
- Agg<float> f3 = {ld}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<float> f2 = {d}; // expected-warning {{non-constant-expression cannot be narrowed from type 'double' to 'float'}} expected-note {{silence}}
+ Agg<float> f3 = {ld}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
// Exact constants.
Agg<float> f4 = {1.0}; // OK (double constant represented exactly)
Agg<float> f5 = {1.0L}; // OK (long double constant represented exactly)
@@ -82,8 +82,8 @@ void shrink_float() {
Agg<float> f6 = {0.1}; // OK (double constant in range but rounded)
Agg<float> f7 = {0.1L}; // OK (long double constant in range but rounded)
// Out of range constants.
- Agg<float> f8 = {1E50}; // expected-warning {{constant expression evaluates to 1.000000e+50 which cannot be narrowed to type 'float'}} expected-note {{override}}
- Agg<float> f9 = {1E50L}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<float> f8 = {1E50}; // expected-warning {{constant expression evaluates to 1.000000e+50 which cannot be narrowed to type 'float'}} expected-note {{silence}}
+ Agg<float> f9 = {1E50L}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
// More complex constant expression.
constexpr long double e40 = 1E40L, e30 = 1E30L, e39 = 1E39L;
Agg<float> f10 = {e40 - 5 * e39 + e30 - 5 * e39}; // OK
@@ -91,19 +91,19 @@ void shrink_float() {
// Variables.
Agg<double> d1 = {f}; // OK (widening)
Agg<double> d2 = {d}; // OK (no-op)
- Agg<double> d3 = {ld}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<double> d3 = {ld}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
// Exact constant.
Agg<double> d4 = {1.0L}; // OK (long double constant represented exactly)
// Inexact but in-range constant.
Agg<double> d5 = {0.1L}; // OK (long double constant in range but rounded)
// Out of range constant.
- Agg<double> d6 = {1E315L}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<double> d6 = {1E315L}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
// More complex constant expression.
constexpr long double e315 = 1E315L, e305 = 1E305L, e314 = 1E314L;
Agg<double> d7 = {e315 - 5 * e314 + e305 - 5 * e314}; // OK
- Agg<float> ce1 = { Convert<double>(1e300) }; // expected-warning {{constant expression evaluates to 1.000000e+300 which cannot be narrowed to type 'float'}} expected-note {{override}}
- Agg<double> ce2 = { ConvertVar<long double>() }; // expected-warning {{non-constant-expression cannot be narrowed from type 'long double' to 'double'}} expected-note {{override}}
+ Agg<float> ce1 = { Convert<double>(1e300) }; // expected-warning {{constant expression evaluates to 1.000000e+300 which cannot be narrowed to type 'float'}} expected-note {{silence}}
+ Agg<double> ce2 = { ConvertVar<long double>() }; // expected-warning {{non-constant-expression cannot be narrowed from type 'long double' to 'double'}} expected-note {{silence}}
}
// * from an integer type or unscoped enumeration type to a floating-point type,
@@ -115,16 +115,16 @@ void int_to_float() {
char c = 1;
// Variables. Yes, even though all char's will fit into any floating type.
- Agg<float> f1 = {c}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
- Agg<double> f2 = {c}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
- Agg<long double> f3 = {c}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<float> f1 = {c}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
+ Agg<double> f2 = {c}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
+ Agg<long double> f3 = {c}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
// Constants.
Agg<float> f4 = {12345678}; // OK (exactly fits in a float)
- Agg<float> f5 = {123456789}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<float> f5 = {123456789}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
- Agg<float> ce1 = { Convert<int>(123456789) }; // expected-warning {{constant expression evaluates to 123456789 which cannot be narrowed to type 'float'}} expected-note {{override}}
- Agg<double> ce2 = { ConvertVar<long long>() }; // expected-warning {{non-constant-expression cannot be narrowed from type 'long long' to 'double'}} expected-note {{override}}
+ Agg<float> ce1 = { Convert<int>(123456789) }; // expected-warning {{constant expression evaluates to 123456789 which cannot be narrowed to type 'float'}} expected-note {{silence}}
+ Agg<double> ce2 = { ConvertVar<long long>() }; // expected-warning {{non-constant-expression cannot be narrowed from type 'long long' to 'double'}} expected-note {{silence}}
}
// * from an integer type or unscoped enumeration type to an integer type that
@@ -136,38 +136,39 @@ void shrink_int() {
// Not a constant expression.
short s = 1;
unsigned short us = 1;
- Agg<char> c1 = {s}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
- Agg<unsigned short> s1 = {s}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
- Agg<short> s2 = {us}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<char> c1 = {s}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
+ Agg<unsigned short> s1 = {s}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
+ Agg<short> s2 = {us}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
// "that cannot represent all the values of the original type" means that the
// validity of the program depends on the relative sizes of integral types.
// This test compiles with -m64, so sizeof(int)<sizeof(long)==sizeof(long
// long).
long l1 = 1;
- Agg<int> i1 = {l1}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<int> i1 = {l1}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
long long ll = 1;
Agg<long> l2 = {ll}; // OK
// Constants.
Agg<char> c2 = {127}; // OK
- Agg<char> c3 = {300}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} expected-warning {{changes value}}
+ Agg<char> c3 = {300}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} expected-warning {{changes value}}
Agg<int> i2 = {0x7FFFFFFFU}; // OK
- Agg<int> i3 = {0x80000000U}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
- Agg<unsigned int> i4 = {-0x80000000L}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<int> i3 = {0x80000000U}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
+ Agg<unsigned int> i4 = {-0x80000000L}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
// Bool is also an integer type, but conversions to it are a different AST
// node.
Agg<bool> b1 = {0}; // OK
Agg<bool> b2 = {1}; // OK
- Agg<bool> b3 = {-1}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<bool> b3 = {-1}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
// Conversions from pointers to booleans aren't narrowing conversions.
- Agg<bool> b = {&b1}; // OK
+ Agg<bool>* ptr = &b1;
+ Agg<bool> b = {ptr}; // OK
- Agg<short> ce1 = { Convert<int>(100000) }; // expected-warning {{constant expression evaluates to 100000 which cannot be narrowed to type 'short'}} expected-note {{override}} expected-warning {{changes value from 100000 to -31072}}
- Agg<char> ce2 = { ConvertVar<short>() }; // expected-warning {{non-constant-expression cannot be narrowed from type 'short' to 'char'}} expected-note {{override}}
+ Agg<short> ce1 = { Convert<int>(100000) }; // expected-warning {{constant expression evaluates to 100000 which cannot be narrowed to type 'short'}} expected-note {{silence}} expected-warning {{changes value from 100000 to -31072}}
+ Agg<char> ce2 = { ConvertVar<short>() }; // expected-warning {{non-constant-expression cannot be narrowed from type 'short' to 'char'}} expected-note {{silence}}
}
// Be sure that type- and value-dependent expressions in templates get the warning
@@ -175,9 +176,9 @@ void shrink_int() {
template<int I, typename T>
void maybe_shrink_int(T t) {
- Agg<short> s1 = {t}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
- Agg<short> s2 = {I}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} expected-warning {{changes value}}
- Agg<T> t2 = {700}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} expected-warning {{changes value}}
+ Agg<short> s1 = {t}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}}
+ Agg<short> s2 = {I}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} expected-warning {{changes value}}
+ Agg<T> t2 = {700}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} expected-warning {{changes value}}
}
void test_template() {
@@ -190,9 +191,9 @@ void test_template() {
void test_qualifiers(int i) {
const int j = i;
- struct {const unsigned char c;} c1 = {j}; // expected-warning {{from type 'int' to 'unsigned char' in}} expected-note {{override}}
+ struct {const unsigned char c;} c1 = {j}; // expected-warning {{from type 'int' to 'unsigned char' in}} expected-note {{silence}}
// Template arguments make it harder to avoid printing qualifiers:
- Agg<const unsigned char> c2 = {j}; // expected-warning {{from type 'int' to 'const unsigned char' in}} expected-note {{override}}
+ Agg<const unsigned char> c2 = {j}; // expected-warning {{from type 'int' to 'const unsigned char' in}} expected-note {{silence}}
}
// Make sure we still get the right SFINAE behavior.
diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp
index 2ec1454100b6..cec747e1d605 100644
--- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp
+++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp
@@ -22,13 +22,13 @@ typedef func_type_rvalue &func_type_rvalue_ref; // expected-error{{reference to
template<typename T = func_type_lvalue> struct wrap {
typedef T val;
- typedef T *ptr;
- typedef T &ref;
+ typedef T *ptr; // expected-error-re 2{{pointer to function type '{{.*}}' cannot have '{{&|&&}}' qualifier}}
+ typedef T &ref; // expected-error-re 2{{reference to function type '{{.*}}' cannot have '{{&|&&}}' qualifier}}
};
-using func_type_lvalue = wrap<>::val;
+using func_type_lvalue = wrap<>::val; // expected-note{{in instantiation of}}
using func_type_lvalue = wrap<func_type_lvalue>::val;
-using func_type_rvalue = wrap<func_type_rvalue>::val;
+using func_type_rvalue = wrap<func_type_rvalue>::val; // expected-note{{in instantiation of}}
using func_type_lvalue_ptr = wrap<>::ptr;
using func_type_lvalue_ptr = wrap<func_type_lvalue>::ptr;
@@ -51,3 +51,10 @@ void (X::*mpf2)() && = &X::f1;
void (f() &&); // expected-error{{non-member function cannot have '&&' qualifier}}
+
+// FIXME: These are ill-formed.
+template<typename T> struct pass {
+ void f(T);
+};
+pass<func_type_lvalue> pass0;
+pass<func_type_lvalue> pass1;
diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp
index e2d94fbf3811..a035086c9a12 100644
--- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp
+++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp
@@ -18,3 +18,16 @@ struct Y {
friend void X::f() const;
friend void ::f() const; // expected-error {{non-member function cannot have 'const' qualifier}}
};
+
+template<typename T> struct S {
+ typedef T F;
+ typedef T *P; // expected-error {{pointer to function type 'void () const' cannot have 'const' qualifier}}
+ typedef T &R; // expected-error {{reference to function type 'void () const' cannot have 'const' qualifier}}
+};
+S<F> s; // expected-note {{in instantiation of}}
+
+// FIXME: This is ill-formed.
+template<typename T> struct U {
+ void f(T);
+};
+U<F> u;
diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp
index ec1ccbf5de5f..0454412229fa 100644
--- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp
+++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp
@@ -1,8 +1,8 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
struct A { };
-A::A (enum { e1 }) {} // expected-error{{can not be defined in a parameter}}
-void A::f(enum { e2 }) {} // expected-error{{can not be defined in a parameter}}
+A::A (enum { e1 }) {} // expected-error{{cannot be defined in a parameter}}
+void A::f(enum { e2 }) {} // expected-error{{cannot be defined in a parameter}}
-enum { e3 } A::g() { } // expected-error{{can not be defined in the result type}} \
+enum { e3 } A::g() { } // expected-error{{cannot be defined in the result type}} \
// expected-error{{out-of-line definition}}
diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p3.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p3.cpp
index 7e35788d898b..e159ab729d5f 100644
--- a/test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p3.cpp
+++ b/test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p3.cpp
@@ -17,7 +17,7 @@ void f() {
A a(b);
int A::*ip = &A::s; // expected-error {{cannot initialize a variable of type 'int A::*' with an rvalue of type 'int *'}}
- a.*&A::s = 10; // expected-error{{right hand operand to .* has non pointer-to-member type 'int *'}}
+ a.*&A::s = 10; // expected-error{{right hand operand to .* has non-pointer-to-member type 'int *'}}
a.*&A::i = 10; // expected-error{{cannot form a pointer-to-member to member 'i' of reference type 'int &'}}
ft(a); // expected-note{{in instantiation of function template specialization 'ft<A>' requested here}}
diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p6-0x.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p6-0x.cpp
index cd623df71e81..0f76e1f3c79b 100644
--- a/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p6-0x.cpp
+++ b/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p6-0x.cpp
@@ -1,5 +1,4 @@
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
-// expected-no-diagnostics
template<typename T, typename U>
struct is_same {
@@ -20,8 +19,8 @@ typedef int& LRI;
typedef int&& RRI;
typedef LRI& r1; CHECK_EQUAL_TYPES(r1, int&);
-typedef const LRI& r2; CHECK_EQUAL_TYPES(r2, int&);
-typedef const LRI&& r3; CHECK_EQUAL_TYPES(r3, int&);
+typedef const LRI& r2; CHECK_EQUAL_TYPES(r2, int&); // expected-warning {{'const' qualifier on reference type 'LRI' (aka 'int &') has no effect}}
+typedef const LRI&& r3; CHECK_EQUAL_TYPES(r3, int&); // expected-warning {{'const' qualifier on reference type 'LRI' (aka 'int &') has no effect}}
typedef RRI& r4; CHECK_EQUAL_TYPES(r4, int&);
typedef RRI&& r5; CHECK_EQUAL_TYPES(r5, int&&);
diff --git a/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp b/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp
index 99334b845aba..1d04d7d2a700 100644
--- a/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp
+++ b/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp
@@ -22,3 +22,83 @@ int decltype(tfoo<T>())::i; // expected-error{{nested name specifier 'decltype(t
template<typename T>
void decltype(tfoo<T>())::func() { // expected-error{{nested name specifier 'decltype(tfoo<T>())::' for declaration does not refer into a class, class template or class template partial specialization}}
}
+
+// An init-declarator named with a qualified-id can refer to an element of the
+// inline namespace set of the named namespace.
+namespace inline_namespaces {
+ namespace N {
+ inline namespace M {
+ void f(); // expected-note {{possible target}}
+ void g();
+ extern int m; // expected-note {{candidate}}
+ extern int n;
+ struct S; // expected-note {{candidate}}
+ struct T;
+ enum E : int; // expected-note {{candidate}}
+ enum F : int;
+ template<typename T> void ft(); // expected-note {{here}}
+ template<typename T> void gt(); // expected-note {{here}}
+ template<typename T> extern int mt; // expected-note {{here}} expected-warning {{extension}}
+ template<typename T> extern int nt; // expected-note {{here}} expected-warning {{extension}}
+ template<typename T> struct U; // expected-note {{here}}
+ template<typename T> struct V; // expected-note {{here}}
+ }
+
+ // When named by unqualified-id, we do *not* look in the inline namespace
+ // set.
+ void f() {} // expected-note {{possible target}}
+ int m; // expected-note {{candidate}}
+ struct S {}; // expected-note {{candidate}}
+ enum E : int {}; // expected-note {{candidate}}
+
+ static_assert(&f != &M::f, ""); // expected-error {{reference to overloaded function could not be resolved}}
+ static_assert(&m != &M::m, ""); // expected-error {{ambiguous}}
+ typedef S X; // expected-error {{ambiguous}}
+ typedef E Y; // expected-error {{ambiguous}}
+
+ // When named by (unqualified) template-id, we do look in the inline
+ // namespace set. See [namespace.def]p8, [temp.explicit]p3,
+ // [temp.expl.spec]p2.
+ //
+ // This is not explicitly specified for partial specializations, but
+ // that is just a language defect.
+ template<> void ft<int>() {}
+ template void ft<char>(); // expected-error {{undefined}}
+
+ template<typename T> int mt<T*>;
+ template<> int mt<int>;
+ template int mt<int*>;
+ template int mt<char>; // expected-error {{undefined}}
+
+ template<typename T> struct U<T*> {};
+ template<> struct U<int> {};
+ template struct U<int*>;
+ template struct U<char>; // expected-error {{undefined}}
+ }
+
+ // When named by qualified-id, we *do* look in the inline namespace set.
+ void N::g() {}
+ int N::n;
+ struct N::T {};
+ enum N::F : int {};
+
+ static_assert(&N::g == &N::M::g, "");
+ static_assert(&N::n == &N::M::n, "");
+ typedef N::T X;
+ typedef N::M::T X;
+ typedef N::F Y;
+ typedef N::M::F Y;
+
+ template<> void N::gt<int>() {}
+ template void N::gt<char>(); // expected-error {{undefined}}
+
+ template<typename T> int N::nt<T*>;
+ template<> int N::nt<int>;
+ template int N::nt<int*>;
+ template int N::nt<char>; // expected-error {{undefined}}
+
+ template<typename T> struct N::V<T*> {};
+ template<> struct N::V<int> {};
+ template struct N::V<int*>;
+ template struct N::V<char>; // expected-error {{undefined}}
+}
diff --git a/test/CXX/dcl.decl/dcl.meaning/p1.cpp b/test/CXX/dcl.decl/dcl.meaning/p1.cpp
index ec9a2611872c..5747380f2806 100644
--- a/test/CXX/dcl.decl/dcl.meaning/p1.cpp
+++ b/test/CXX/dcl.decl/dcl.meaning/p1.cpp
@@ -29,9 +29,17 @@ namespace NS {
template<typename T> void wibble(T);
}
namespace NS {
- void NS::foo() {} // expected-error{{extra qualification on member 'foo'}}
- int NS::bar; // expected-error{{extra qualification on member 'bar'}}
- struct NS::X { }; // expected-error{{extra qualification on member 'X'}}
- template<typename T> struct NS::Y; // expected-error{{extra qualification on member 'Y'}}
- template<typename T> void NS::wibble(T) { } // expected-error{{extra qualification on member 'wibble'}}
+ // Under DR482, these are all valid, except for forward-declaring a struct
+ // with a nested-name-specifier.
+ void NS::foo(); // expected-warning {{extra qualification}}
+ extern int NS::bar; // expected-warning {{extra qualification}}
+ struct NS::X; // expected-error {{forward declaration of struct cannot have a nested name specifier}} expected-warning {{extra qualification}}
+ template<typename T> struct NS::Y; // expected-error {{forward declaration of struct cannot have a nested name specifier}} expected-warning {{extra qualification}}
+ template<typename T> void NS::wibble(T); // expected-warning {{extra qualification}}
+
+ void NS::foo() {} // expected-warning{{extra qualification on member 'foo'}}
+ int NS::bar; // expected-warning{{extra qualification on member 'bar'}}
+ struct NS::X { }; // expected-warning{{extra qualification on member 'X'}}
+ template<typename T> struct NS::Y { }; // expected-warning{{extra qualification on member 'Y'}}
+ template<typename T> void NS::wibble(T) { } // expected-warning{{extra qualification on member 'wibble'}}
}