[PATCH] D39859: [OpenMP] diagnose assign to firstprivate const

Alexey Bataev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 9 13:21:03 PST 2017

ABataev added inline comments.

Comment at: lib/Sema/SemaExpr.cpp:14356
+    if (S.IsOpenMPCapturedDecl(Var)) {
+      bool hasConst = DeclRefType.isConstQualified();
       DeclRefType = DeclRefType.getUnqualifiedType();
`hasConst` must start from capital letter `HasConst`.

Comment at: lib/Sema/SemaExpr.cpp:14360
+      if (hasConst)
+        DeclRefType = QualType(DeclRefType.getTypePtr(), Qualifiers::Const);
+    }
Better to make it this way:

Comment at: test/OpenMP/parallel_firstprivate_messages.cpp:75
   #pragma omp parallel firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
+    d = 5; // expected-error {{cannot assign to variable 'd' with const-qualified type}}
   #pragma omp parallel firstprivate (argv[1]) // expected-error {{expected variable name}}
Please, add a separate directive with this assignment


More information about the cfe-commits mailing list