r236571 - [OPENMP] Fix for http://llvm.org/PR23387: clang fails to compile magick/attribute.c
Alexey Bataev
a.bataev at hotmail.com
Tue May 5 23:34:55 PDT 2015
Author: abataev
Date: Wed May 6 01:34:55 2015
New Revision: 236571
URL: http://llvm.org/viewvc/llvm-project?rev=236571&view=rev
Log:
[OPENMP] Fix for http://llvm.org/PR23387: clang fails to compile magick/attribute.c
Allow to use variables with 'register' storage class as loop control variables in OpenMP loop based constructs.
Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/for_loop_messages.cpp
Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=236571&r1=236570&r2=236571&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed May 6 01:34:55 2015
@@ -426,7 +426,8 @@ DSAStackTy::DSAVarData DSAStackTy::getTo
// in a Construct, C/C++, predetermined, p.1]
// Variables appearing in threadprivate directives are threadprivate.
if (D->getTLSKind() != VarDecl::TLS_None ||
- D->getStorageClass() == SC_Register) {
+ (D->getStorageClass() == SC_Register && D->hasAttr<AsmLabelAttr>() &&
+ !D->isLocalVarDecl())) {
DVar.CKind = OMPC_threadprivate;
return DVar;
}
@@ -885,7 +886,8 @@ Sema::CheckOMPThreadPrivateDecl(SourceLo
// Check if this is a TLS variable.
if (VD->getTLSKind() != VarDecl::TLS_None ||
- VD->getStorageClass() == SC_Register) {
+ (VD->getStorageClass() == SC_Register && VD->hasAttr<AsmLabelAttr>() &&
+ !VD->isLocalVarDecl())) {
Diag(ILoc, diag::err_omp_var_thread_local)
<< VD << ((VD->getTLSKind() != VarDecl::TLS_None) ? 0 : 1);
bool IsDecl =
Modified: cfe/trunk/test/OpenMP/for_loop_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_loop_messages.cpp?rev=236571&r1=236570&r2=236571&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/for_loop_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/for_loop_messages.cpp Wed May 6 01:34:55 2015
@@ -13,12 +13,15 @@ static int sii;
#pragma omp threadprivate(sii) // expected-note {{defined as threadprivate or thread local}}
static int globalii;
+register int reg0 __asm__("0"); // expected-note {{loop iteration variable is predetermined as linear}}
+
int test_iteration_spaces() {
const int N = 100;
float a[N], b[N], c[N];
int ii, jj, kk;
float fii;
double dii;
+ register int reg; // expected-warning {{'register' storage class specifier is deprecated}}
#pragma omp parallel
#pragma omp for
for (int i = 0; i < 10; i += 1) {
@@ -312,6 +315,21 @@ int test_iteration_spaces() {
}
#pragma omp parallel
+ {
+// expected-error at +2 {{loop iteration variable in the associated loop of 'omp for' directive may not be threadprivate or thread local, predetermined as private}}
+#pragma omp for
+ for (reg0 = 0; reg0 < 10; reg0 += 1)
+ c[reg0] = a[reg0];
+ }
+
+#pragma omp parallel
+ {
+#pragma omp for
+ for (reg = 0; reg < 10; reg += 1)
+ c[reg] = a[reg];
+ }
+
+#pragma omp parallel
{
#pragma omp for
for (globalii = 0; globalii < 10; globalii += 1)
More information about the cfe-commits
mailing list