| 1 |
// Tests that the ODR check wouldn't produce false-positive result for preferred_name attribute. |
| 2 |
// |
| 3 |
// RUN: rm -rf %t |
| 4 |
// RUN: mkdir -p %t |
| 5 |
// RUN: split-file %s %t |
| 6 |
// |
| 7 |
// RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-module-interface -o %t/A.pcm |
| 8 |
// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -I%t %t/Use.cppm -verify -fsyntax-only |
| 9 |
// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -I%t %t/Use1.cpp -verify -fsyntax-only |
| 10 |
// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -I%t %t/Use2.cpp -verify -fsyntax-only |
| 11 |
|
| 12 |
// Test again with reduced BMI. |
| 13 |
// RUN: rm -rf %t |
| 14 |
// RUN: mkdir -p %t |
| 15 |
// RUN: split-file %s %t |
| 16 |
// |
| 17 |
// RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-reduced-module-interface -o %t/A.pcm |
| 18 |
// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -I%t %t/Use.cppm -verify -fsyntax-only |
| 19 |
// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -I%t %t/Use1.cpp -verify -fsyntax-only |
| 20 |
// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -I%t %t/Use2.cpp -verify -fsyntax-only |
| 21 |
// |
| 22 |
//--- foo.h |
| 23 |
template<class _CharT> |
| 24 |
class foo_templ; |
| 25 |
|
| 26 |
typedef foo_templ<char> foo; |
| 27 |
|
| 28 |
template<class _CharT> |
| 29 |
class |
| 30 |
__attribute__((__preferred_name__(foo))) |
| 31 |
foo_templ { |
| 32 |
public: |
| 33 |
foo_templ() {} |
| 34 |
}; |
| 35 |
|
| 36 |
inline foo_templ<char> bar() |
| 37 |
{ |
| 38 |
return foo_templ<char>(); |
| 39 |
} |
| 40 |
|
| 41 |
//--- A.cppm |
| 42 |
module; |
| 43 |
#include "foo.h" |
| 44 |
export module A; |
| 45 |
export using ::foo_templ; |
| 46 |
|
| 47 |
//--- Use.cppm |
| 48 |
// expected-no-diagnostics |
| 49 |
module; |
| 50 |
#include "foo.h" |
| 51 |
export module Use; |
| 52 |
import A; |
| 53 |
export using ::foo_templ; |
| 54 |
|
| 55 |
//--- Use1.cpp |
| 56 |
import A; // [email protected]:8 {{attribute declaration must precede definition}} |
| 57 |
#include "foo.h" // [email protected]:9 {{previous definition is here}} |
| 58 |
|
| 59 |
//--- Use2.cpp |
| 60 |
// expected-no-diagnostics |
| 61 |
#include "foo.h" |
| 62 |
import A; |