Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang] Add tests for CWG issues about language linkage #107019

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions clang/test/CXX/drs/cwg1818.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// RUN: %clang_cc1 -std=c++98 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s
// RUN: %clang_cc1 -std=c++11 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s
// RUN: %clang_cc1 -std=c++14 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s
// RUN: %clang_cc1 -std=c++17 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s
// RUN: %clang_cc1 -std=c++20 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s
// RUN: %clang_cc1 -std=c++23 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s
// RUN: %clang_cc1 -std=c++2c %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s

// expected-no-diagnostics

namespace cwg1818 { // cwg1818: 3.4
extern "C" void f() {
// This declaration binds name 'g' in the scope of function 'f',
// but its target scope corresponds to namespace 'cwg1818' (_N4988_.[dcl.meaning]/3.5).
// Linkage specification of 'f' applies to 'g' per _N4988_.[dcl.link]/5.
void g();
}
// Target scope of this declaration is naturally the one
// that corresponds to namespace 'cwg1818',
// which makes it declare the same entity
// as the previous declaration per _N4988_.[basic.link]/8,
// turning it into a redeclaration per _N4988_.[basic.def]/1.
// Then _N4988_.[dcl.link]/6 applies, making it inherit
// the (С) language linkage of the previous declaration.
void g();
} // namespace cwg1818

// Check that the former 'g' has C language linkage,
// then that the latter 'g' is considered to be a redeclaration of it,
// which would make the latter 'g' inherit C language linkage from the former 'g'.

// CHECK: LinkageSpecDecl [[LINKAGE_DECL:0x[0-9a-f]+]] {{.*}} C
// CHECK: FunctionDecl [[FIRST_DECL:0x[0-9a-f]+]] parent [[LINKAGE_DECL]] {{.*}} g 'void ()'
// CHECK: FunctionDecl {{.*}} prev [[FIRST_DECL]] {{.*}} g 'void ()'
2 changes: 2 additions & 0 deletions clang/test/CXX/drs/cwg18xx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ namespace cwg1815 { // cwg1815: no
#endif
}

// cwg1818 is in cwg1818.cpp

namespace cwg1820 { // cwg1820: 3.5
typedef int A;
typedef int cwg1820::A;
Expand Down
16 changes: 16 additions & 0 deletions clang/test/CXX/drs/cwg563.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// RUN: %clang_cc1 -std=c++98 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s
// RUN: %clang_cc1 -std=c++11 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s
// RUN: %clang_cc1 -std=c++14 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s
// RUN: %clang_cc1 -std=c++17 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s
// RUN: %clang_cc1 -std=c++20 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s
// RUN: %clang_cc1 -std=c++23 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s
// RUN: %clang_cc1 -std=c++2c %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s

// expected-no-diagnostics

namespace cwg563 { // cwg563: 3.3
extern "C" int a;
} // namespace cwg563

// CHECK: LinkageSpecDecl {{.*}} C
// CHECK-NEXT: `-VarDecl {{.*}} a 'int'
1 change: 1 addition & 0 deletions clang/test/CXX/drs/cwg5xx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ namespace cwg561 { // cwg561: yes
}

// cwg562: na
// cwg563 is in cwg563.cpp

namespace cwg564 { // cwg564: yes
extern "C++" void f(int);
Expand Down
4 changes: 2 additions & 2 deletions clang/www/cxx_dr_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -3431,7 +3431,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://cplusplus.github.io/CWG/issues/563.html">563</a></td>
<td>CD6</td>
<td>Linkage specification for objects</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Clang 3.3</td>
</tr>
<tr id="564">
<td><a href="https://cplusplus.github.io/CWG/issues/564.html">564</a></td>
Expand Down Expand Up @@ -10735,7 +10735,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://cplusplus.github.io/CWG/issues/1818.html">1818</a></td>
<td>CD6</td>
<td>Visibility and inherited language linkage</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Clang 3.4</td>
</tr>
<tr id="1819">
<td><a href="https://cplusplus.github.io/CWG/issues/1819.html">1819</a></td>
Expand Down
Loading