brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.7 KiB · da6fe01 Raw
127 lines · cpp
1// RUN: rm -rf %t2// RUN: mkdir %t3// RUN: split-file %s %t4//5// RUN: %clang_cc1  -std=c++20 %t/foo.cppm -I%t -emit-module-interface -o %t/foo.pcm6// RUN: %clang_cc1  -fprebuilt-module-path=%t -std=c++20 %t/use.cpp -I%t/. -fsyntax-only -verify7 8// RUN: %clang_cc1  -std=c++20 %t/foo.cppm -I%t -emit-reduced-module-interface -o %t/foo.pcm9// RUN: %clang_cc1  -fprebuilt-module-path=%t -std=c++20 %t/use.cpp -I%t/. -fsyntax-only -verify10 11//--- foo.h12template <typename T = int>13T v;14 15template <int T = 8>16int v2;17 18template <typename T>19class my_array {};20 21template <template <typename> typename C = my_array>22int v3;23 24template <typename T, int *i = nullptr>25T v4;26 27template <typename T, T *i = nullptr>28T v5;29 30inline int a = 43;31template <typename T, int *i = &a>32T v6;33 34inline int b = 43;35template <typename T, T *i = &b>36T v7;37 38template <int T = (3 > 2)>39int v8;40 41consteval int getInt() {42  return 55;43}44template <int T = getInt()>45int v9;46 47//--- foo_bad.h48template <typename T = double>49T v;50 51template <int T = 9>52int v2;53 54template <typename T>55class others_array {};56 57template <template <typename> typename C = others_array>58int v3;59 60static int a;61consteval int *getIntPtr() {62  return &a;63}64template <typename T, int *i = getIntPtr()>65T v4;66 67consteval void *getVoidPtr() {68  return &a;69}70template <typename T, T *i = getVoidPtr()>71T v5;72 73inline int a_ = 43;74template <typename T, int *i = &a_>75T v6;76 77inline int b_ = 43;78template <typename T, T *i = &b_>79T v7;80 81template <int T = -1>82int v8;83 84consteval int getInt2() {85  return 55;86}87template <int T = getInt2()>88int v9;89 90//--- foo.cppm91module;92#include "foo.h"93export module foo;94export using ::v;95export using ::v2;96export using ::my_array;97export using ::v3;98export using ::v4;99export using ::v5;100export using ::v6;101export using ::v7;102export using ::v8;103export using ::v9;104 105//--- use.cpp106import foo;107#include "foo_bad.h"108 109// expected-error@foo_bad.h:1 {{template parameter default argument is inconsistent with previous definition}}110// expected-note@foo.h:1 {{previous default template argument defined in module foo.<global>}}111// expected-error@foo_bad.h:4 {{template parameter default argument is inconsistent with previous definition}}112// expected-note@foo.h:4 {{previous default template argument defined in module foo.<global>}}113// expected-error@foo_bad.h:10 {{template parameter default argument is inconsistent with previous definition}}114// expected-note@foo.h:10 {{previous default template argument defined in module foo.<global>}}115// expected-error@foo_bad.h:17 {{template parameter default argument is inconsistent with previous definition}}116// expected-note@foo.h:13 {{previous default template argument defined in module foo.<global>}}117// expected-error@foo_bad.h:23 {{template parameter default argument is inconsistent with previous definition}}118// expected-note@foo.h:16 {{previous default template argument defined in module foo.<global>}}119// expected-error@foo_bad.h:27 {{template parameter default argument is inconsistent with previous definition}}120// expected-note@foo.h:20 {{previous default template argument defined in module foo.<global>}}121// expected-error@foo_bad.h:31 {{template parameter default argument is inconsistent with previous definition}}122// expected-note@foo.h:24 {{previous default template argument defined in module foo.<global>}}123// expected-error@foo_bad.h:34 {{template parameter default argument is inconsistent with previous definition}}124// expected-note@foo.h:27 {{previous default template argument defined in module foo.<global>}}125// expected-error@foo_bad.h:40 {{template parameter default argument is inconsistent with previous definition}}126// expected-note@foo.h:33 {{previous default template argument defined in module foo.<global>}}127