63 lines · plain
1// Tests that the ODR check wouldn't produce false-positive result for preferred_name attribute.2//3// RUN: rm -rf %t4// RUN: mkdir -p %t5// RUN: split-file %s %t6//7// RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-module-interface -o %t/A.pcm8// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -I%t %t/Use.cppm -verify -fsyntax-only9// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -I%t %t/Use1.cpp -verify -fsyntax-only10// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -I%t %t/Use2.cpp -verify -fsyntax-only11 12// Test again with reduced BMI.13// RUN: rm -rf %t14// RUN: mkdir -p %t15// RUN: split-file %s %t16//17// RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-reduced-module-interface -o %t/A.pcm18// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -I%t %t/Use.cppm -verify -fsyntax-only19// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -I%t %t/Use1.cpp -verify -fsyntax-only20// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -I%t %t/Use2.cpp -verify -fsyntax-only21//22//--- foo.h23template<class _CharT>24class foo_templ;25 26typedef foo_templ<char> foo;27 28template<class _CharT>29class30__attribute__((__preferred_name__(foo)))31foo_templ {32public:33 foo_templ() {}34};35 36inline foo_templ<char> bar()37{38 return foo_templ<char>();39}40 41//--- A.cppm42module;43#include "foo.h"44export module A;45export using ::foo_templ;46 47//--- Use.cppm48// expected-no-diagnostics49module;50#include "foo.h"51export module Use;52import A;53export using ::foo_templ;54 55//--- Use1.cpp56import A; // expected-warning@foo.h:8 {{attribute declaration must precede definition}}57#include "foo.h" // expected-note@foo.h:9 {{previous definition is here}}58 59//--- Use2.cpp60// expected-no-diagnostics61#include "foo.h"62import A;63