Skip to content

Commit b54bd17

Browse files
committed
handle arrays & func ptrs better
1 parent 0fcfcfe commit b54bd17

File tree

8 files changed

+43
-42
lines changed

8 files changed

+43
-42
lines changed

clang/lib/Parse/ParsePragma.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,12 +1455,10 @@ bool Parser::zOSParseParameterList(
14551455
TypeList = SmallVector<QualType, 4>();
14561456
PP.Lex(Tok);
14571457
while (Tok.isNot(tok::eof) && !Tok.is(tok::r_paren)) {
1458-
TypeResult TResult = ParseTypeName(nullptr, DeclaratorContext::Prototype);
1458+
TypeResult TResult = ParseTypeName(nullptr);
14591459
if (!TResult.isInvalid()) {
14601460
QualType QT = TResult.get().get();
14611461
if (!QT.getTypePtr()->isVoidType()) {
1462-
fprintf(stderr, "SDP: paramType -\n");
1463-
QT.getCanonicalType()->dump();
14641462
TypeList->push_back(QT);
14651463
}
14661464
}

clang/lib/Sema/SemaAttr.cpp

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,11 @@ void Sema::AddImplicitMSFunctionNoBuiltinAttr(FunctionDecl *FD) {
13231323
FD->addAttr(NoBuiltinAttr::CreateImplicit(Context, V.data(), V.size()));
13241324
}
13251325

1326-
static bool typeListMatches(ASTContext& Context, FunctionDecl *FD,
1326+
static QualType getCanonicalParamType(ASTContext &C, QualType T) {
1327+
return C.getCanonicalParamType(T);
1328+
}
1329+
1330+
static bool typeListMatches(ASTContext &Context, FunctionDecl *FD,
13271331
const clang::Sema::SymbolLabel &Label) {
13281332
assert(Label.TypeList.has_value());
13291333
if (FD->getNumParams() != Label.TypeList->size()) {
@@ -1334,25 +1338,10 @@ static bool typeListMatches(ASTContext& Context, FunctionDecl *FD,
13341338
for (unsigned i = 0; i != FD->getNumParams(); ++i) {
13351339
const ParmVarDecl *PVD = FD->getParamDecl(i);
13361340
QualType ParmType = PVD->getType().getCanonicalType();
1337-
#if SDP
1338-
// SDP QualType ParmType = PVD->getOriginalType().getCanonicalType();
1339-
if (ParmType->isArrayType())
1340-
ParmType = Context.getArrayDecayedType(ParmType);
1341-
else if (ParmType->isFunctionType())
1342-
ParmType = Context.getPointerType(ParmType);
1343-
#endif
1344-
1345-
QualType MapArgType = (*Label.TypeList)[i].getCanonicalType();
1346-
#if SDP
1347-
if (MapArgType->isArrayType())
1348-
MapArgType = Context.getArrayDecayedType(MapArgType);
1349-
else if (MapArgType->isFunctionType())
1350-
MapArgType = Context.getPointerType(MapArgType);
1351-
MapArgType.getDesugaredType(Context)->dump();
1352-
1353-
assert(!ParmType->canDecayToPointerType());
1354-
assert(!MapArgType->canDecayToPointerType());
1355-
#endif
1341+
1342+
QualType MapArgType =
1343+
getCanonicalParamType(Context, (*Label.TypeList)[i].getCanonicalType());
1344+
13561345
if (ParmType != MapArgType)
13571346
return false;
13581347
}

clang/test/CodeGen/attr-export.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class _Export class1 {
2929
public:
3030
void foo();
3131
};
32-
#if 0
3332

3433
class class2 {
3534
public:
@@ -51,4 +50,3 @@ class class3 {
5150

5251
void class3::foo() {};
5352
void class3::bar() {};
54-
#endif

clang/test/CodeGen/pragma-export.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// REQUIRES: systemz-registered-target
2-
// RUN: %clang_cc1 %s -emit-llvm -fzos-extensions -triple s390x-none-zos -fvisibility=hidden -verify -o - | FileCheck %s
2+
// RUN: %clang_cc1 %s -emit-llvm -fzos-extensions -triple s390x-none-zos -fvisibility=hidden -o - | FileCheck %s
33

44
// Testing pragma export after decl.
55
void f0(void) {}

clang/test/CodeGen/pragma-export.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,17 @@
11
// REQUIRES: systemz-registered-target
2-
// RUN: %clang_cc1 %s -emit-llvm -triple s390x-none-zos -fzos-extensions -fvisibility=hidden -verify -o - | FileCheck %s
3-
4-
// Testing missing declarations.
5-
#pragma export(d0) // expected-warning{{failed to resolve '#pragma export' to a declaration}}
6-
#pragma export(f9) // expected-warning{{failed to resolve '#pragma export' to a declaration}}
7-
#pragma export(f0(int)) // expected-warning{{failed to resolve '#pragma export' to a declaration}}
8-
#pragma export(f3(double, double, double)) // expected-warning{{failed to resolve '#pragma export' to a declaration}}
2+
// RUN: %clang_cc1 -x c++ %s -emit-llvm -triple s390x-none-zos -fzos-extensions -fvisibility=hidden -o - | FileCheck %s
93

104
// Testing pragma export after decl.
115
void f0(void) {}
12-
static void sf0(void) {} // expected-warning{{#pragma export is applicable to symbols with external linkage only; not applied to 'sf0'}}
136
int v0;
14-
static int s0; // expected-warning{{#pragma export is applicable to symbols with external linkage only; not applied to 's0'}}
157
#pragma export(f0)
16-
#pragma export(sf0)
178
#pragma export(v0)
18-
#pragma export(s0)
199

2010
// Testing pragma export before decl.
2111
#pragma export(f1)
22-
#pragma export(sf1)
2312
#pragma export(v1)
24-
#pragma export(s1)
2513
void f1(void) {}
26-
static void sf1(void) {} // expected-warning{{#pragma export is applicable to symbols with external linkage only; not applied to 'sf1'}}
2714
int v1;
28-
static int s1; // expected-warning{{#pragma export is applicable to symbols with external linkage only; not applied to 's1'}}
2915

3016
// Testing overloaded functions.
3117
#pragma export(f2(double, double))

clang/test/Sema/attr-export-failing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// REQUIRES: systemz-registered-target
2-
// RUN: not %clang_cc1 -triple s390x-none-zos -fzos-extensions %s -fsyntax-only -verify
2+
// RUN: %clang_cc1 -triple s390x-none-zos -fzos-extensions %s -fsyntax-only -verify
33
__attribute__((visibility("hidden"))) int _Export i; // expected-error {{visibility does not match previous declaration}}
44
class __attribute__((visibility("hidden"))) _Export C; // expected-error {{visibility does not match previous declaration}}
55

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// REQUIRES: systemz-registered-target
2+
// RUN: %clang_cc1 -triple s390x-none-zos -fzos-extensions %s -fsyntax-only -verify
3+
4+
#pragma export(d0) // expected-warning{{failed to resolve '#pragma export' to a declaration}}
5+
#pragma export(f9) // expected-warning{{failed to resolve '#pragma export' to a declaration}}
6+
#pragma export(f0(int)) // expected-warning{{failed to resolve '#pragma export' to a declaration}}
7+
#pragma export(f3(double, double, double)) // expected-warning{{failed to resolve '#pragma export' to a declaration}}
8+
9+
#pragma export(sf1)
10+
#pragma export(s1)
11+
static void sf1(void) {} // expected-warning{{#pragma export is applicable to symbols with external linkage only; not applied to 'sf1'}}
12+
static int s1; // expected-warning{{#pragma export is applicable to symbols with external linkage only; not applied to 's1'}}
13+
14+
static void sf0(void) {} // expected-warning{{#pragma export is applicable to symbols with external linkage only; not applied to 'sf0'}}
15+
int v0;
16+
static int s0; // expected-warning{{#pragma export is applicable to symbols with external linkage only; not applied to 's0'}}
17+
#pragma export(sf0)
18+
#pragma export(s0)

clang/test/Sema/zos-export.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %clang_cc1 -triple s390x-ibm-zos %s -fsyntax-only -verify
2+
3+
typedef int _Export ty;
4+
ty x;
5+
int f(int _Export x);
6+
static int _Export s;
7+
struct S {
8+
int _Export nonstaticdatamember;
9+
};
10+
void g() {
11+
int _Export automatic;
12+
}

0 commit comments

Comments
 (0)