xref: /llvm-project/clang/test/CXX/drs/cwg441.cpp (revision ed128c7df9b4e60bfd814dc9fd22de1dde4a2c1c)
1 // RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
2 // RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
3 // RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
4 // RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
5 // RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
6 // RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
7 // RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
8 
9 namespace cwg441 { // cwg441: 2.7
10 
11 struct A {
Acwg441::A12   A() {}
13 };
14 
15 A dynamic_init;
16 int i;
17 int& ir = i;
18 int* ip = &i;
19 
20 } // namespace cwg441
21 
22 // CHECK-DAG:   @cwg441::dynamic_init = global %"struct.cwg441::A" zeroinitializer
23 // CHECK-DAG:   @cwg441::i = global i32 0
24 // CHECK-DAG:   @cwg441::ir = constant ptr @cwg441::i
25 // CHECK-DAG:   @cwg441::ip = global ptr @cwg441::i
26 // CHECK-DAG:   @llvm.global_ctors = appending global [{{.+}}] [{ {{.+}} } { {{.+}}, ptr @_GLOBAL__sub_I_cwg441.cpp, {{.+}} }]
27 
28 // CHECK-LABEL: define {{.*}} void @__cxx_global_var_init()
29 // CHECK-NEXT:  entry:
30 // CHECK-NEXT:    call void @cwg441::A::A()({{.*}} @cwg441::dynamic_init)
31 // CHECK-NEXT:    ret void
32 // CHECK-NEXT:  }
33 
34 // CHECK-LABEL: define {{.*}} void @_GLOBAL__sub_I_cwg441.cpp()
35 // CHECK-NEXT:  entry:
36 // CHECK-NEXT:    call void @__cxx_global_var_init()
37 // CHECK-NEXT:    ret void
38 // CHECK-NEXT:  }
39