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//--- foo.h 13template<class _CharT> 14class foo_templ; 15 16typedef foo_templ<char> foo; 17 18template<class _CharT> 19class 20__attribute__((__preferred_name__(foo))) 21foo_templ { 22public: 23 foo_templ() {} 24}; 25 26inline foo_templ<char> bar() 27{ 28 return foo_templ<char>(); 29} 30 31//--- A.cppm 32module; 33#include "foo.h" 34export module A; 35 36//--- Use.cppm 37// expected-no-diagnostics 38module; 39#include "foo.h" 40export module Use; 41import A; 42 43//--- Use1.cpp 44import A; // [email protected]:8 {{attribute declaration must precede definition}} 45#include "foo.h" // [email protected]:9 {{previous definition is here}} 46 47//--- Use2.cpp 48// expected-no-diagnostics 49#include "foo.h" 50import A; 51