summaryrefslogtreecommitdiffstats
path: root/test/Modules/redefinition-c-tagtypes.m
blob: a01f11bd74c8b7e1842a94890eaf8f2ba0ce4d7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// RUN: rm -rf %t.cache
// RUN: %clang_cc1 -fsyntax-only %s -fmodules -fmodules-cache-path=%t.cache \
// RUN:   -fimplicit-module-maps -F%S/Inputs -verify
// RUN: %clang_cc1 -fsyntax-only %s -fmodules -fmodules-cache-path=%t.cache \
// RUN:   -fimplicit-module-maps -F%S/Inputs -DCHANGE_TAGS -verify
#include "F/F.h"

#ifndef CHANGE_TAGS
// expected-no-diagnostics
#endif

struct NS {
  int a;
#ifndef CHANGE_TAGS
  int b;
#else
  int c; // expected-note {{field has name 'c' here}}
  // expected-error@redefinition-c-tagtypes.m:12 {{type 'struct NS' has incompatible definitions}}
  // expected-note@Inputs/F.framework/PrivateHeaders/NS.h:3 {{field has name 'b' here}}
#endif
};

enum NSE {
  FST = 22,
#ifndef CHANGE_TAGS
  SND = 43,
#else
  SND = 44, // expected-note {{enumerator 'SND' with value 44 here}}
  // expected-error@redefinition-c-tagtypes.m:23 {{type 'enum NSE' has incompatible definitions}}
  // expected-note@Inputs/F.framework/PrivateHeaders/NS.h:8 {{enumerator 'SND' with value 43 here}}
#endif
  TRD = 55
};

#define NS_ENUM(_type, _name) \
  enum _name : _type _name;   \
  enum _name : _type

typedef NS_ENUM(int, NSMyEnum) {
  MinX = 11,
#ifndef CHANGE_TAGS
  MinXOther = MinX,
#else
  MinXOther = TRD, // expected-note {{enumerator 'MinXOther' with value 55 here}}
  // expected-error@redefinition-c-tagtypes.m:39 {{type 'enum NSMyEnum' has incompatible definitions}}
  // expected-note@Inputs/F.framework/PrivateHeaders/NS.h:18 {{enumerator 'MinXOther' with value 11 here}}
#endif
};