Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CXX / drs / dr11xx.cpp
blob23756ff1927eccf3378142a4c850ec1caf835fad
1 // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
2 // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
3 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
4 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
5 // RUN: %clang_cc1 -std=c++2a %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
7 namespace dr1111 { // dr1111: yes
8 namespace example1 {
9 template <typename> struct set;
11 struct X {
12 template <typename T> void set(const T &value);
14 void foo() {
15 X x;
16 #pragma clang diagnostic push
17 #if __cplusplus < 201103L
18 #pragma clang diagnostic ignored "-Wambiguous-member-template"
19 #endif
20 x.set<double>(3.2);
21 #pragma clang diagnostic pop
24 struct Y {};
25 void bar() {
26 Y y;
27 y.set<double>(3.2); // expected-error {{no member named 'set' in 'dr1111::example1::Y'}}
29 } // namespace example1
31 namespace example2 {
32 struct A {};
33 namespace N {
34 struct A {
35 void g() {}
36 template <class T> operator T();
38 } // namespace N
40 void baz() {
41 N::A a;
42 a.operator A();
44 } // namespace example2
45 } // namespace dr1111
47 namespace dr1113 { // dr1113: partial
48 namespace named {
49 extern int a; // expected-note {{previous}}
50 static int a; // expected-error {{static declaration of 'a' follows non-static}}
52 namespace {
53 extern int a;
54 static int a; // ok, both declarations have internal linkage
55 int b = a;
58 // FIXME: Per DR1113 and DR4, this is ill-formed due to ambiguity: the second
59 // 'f' has internal linkage, and so does not have C language linkage, so is
60 // not a redeclaration of the first 'f'.
62 // To avoid a breaking change here, Clang ignores the "internal linkage" effect
63 // of anonymous namespaces on declarations declared within an 'extern "C"'
64 // linkage-specification.
65 extern "C" void f();
66 namespace {
67 extern "C" void f();
69 void g() { f(); }