summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-10-16 21:12:00 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-10-16 21:12:00 +0000
commit9a00bbfa4c118b4b65f9976beb70c65c0ee1d49c (patch)
tree9727c647b876c36732ee88977bfc17ed7a9f0d67 /clang/test
parent00eef17dbe75f9767e8c2925af2e6ae5636324d6 (diff)
downloadbcm5719-llvm-9a00bbfa4c118b4b65f9976beb70c65c0ee1d49c.tar.gz
bcm5719-llvm-9a00bbfa4c118b4b65f9976beb70c65c0ee1d49c.zip
PR17592: Ensure we diagnose shadowing a template parameter with a local extern
declaration. llvm-svn: 192846
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CXX/temp/temp.res/temp.local/p6.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/clang/test/CXX/temp/temp.res/temp.local/p6.cpp b/clang/test/CXX/temp/temp.res/temp.local/p6.cpp
new file mode 100644
index 00000000000..eccbb899321
--- /dev/null
+++ b/clang/test/CXX/temp/temp.res/temp.local/p6.cpp
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -verify %s -fcxx-exceptions -std=c++1y
+
+template<typename T, // expected-note {{declared here}}
+ typename T> struct X {}; // expected-error {{declaration of 'T' shadows template parameter}}
+
+template<typename T> struct Y { // expected-note 15{{declared here}}
+ template<typename T> struct A {}; // expected-error {{declaration of 'T' shadows template parameter}}
+
+ struct B {
+ template<typename> struct T {}; // FIXME: desired-error {{declaration of 'T' shadows template parameter}}
+ };
+ struct C {
+ template<typename> void T(); // expected-error {{declaration of 'T' shadows template parameter}}
+ };
+ struct D {
+ struct T {}; // expected-error {{declaration of 'T' shadows template parameter}}
+ };
+ struct E {
+ typedef int T; // expected-error {{declaration of 'T' shadows template parameter}}
+ };
+ struct F {
+ using T = int; // expected-error {{declaration of 'T' shadows template parameter}}
+ };
+ struct G {
+ int T; // expected-error {{declaration of 'T' shadows template parameter}}
+ };
+ struct H {
+ static int T; // expected-error {{declaration of 'T' shadows template parameter}}
+ };
+ struct I {
+ void T(); // expected-error {{declaration of 'T' shadows template parameter}}
+ };
+ struct J {
+ enum T { e }; // expected-error {{declaration of 'T' shadows template parameter}}
+ };
+ struct K {
+ enum E { T }; // expected-error {{declaration of 'T' shadows template parameter}}
+ };
+
+ void a() {
+ extern int T; // expected-error {{declaration of 'T' shadows template parameter}}
+ }
+ void b() {
+ int T; // expected-error {{declaration of 'T' shadows template parameter}}
+ }
+ void c() {
+ try {}
+ catch (int T) {} // expected-error {{declaration of 'T' shadows template parameter}}
+ }
+ void d() {
+ void T(); // expected-error {{declaration of 'T' shadows template parameter}}
+ }
+
+ friend struct T; // expected-error {{declaration of 'T' shadows template parameter}}
+};
+
+template<typename T> // expected-note {{declared here}}
+void f(int T) {} // expected-error {{declaration of 'T' shadows template parameter}}
+
+// FIXME: These are ill-formed: a template-parameter shall not have the same name as the template name.
+namespace A {
+ template<typename T> struct T {};
+}
+namespace B {
+ template<typename T> void T() {}
+}
+namespace C {
+ template<typename T> int T;
+}
OpenPOWER on IntegriCloud