]> granicus.if.org Git - clang/commitdiff
Fix PR26543: add a check for definition in CXXRecordDecl.
authorAlexey Bataev <a.bataev@hotmail.com>
Wed, 10 Feb 2016 10:50:12 +0000 (10:50 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Wed, 10 Feb 2016 10:50:12 +0000 (10:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@260370 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOpenMP.cpp
test/OpenMP/parallel_messages.cpp

index 3ba5daa03042f246562acf320e6335e99bef252c..9f4daeeffe9f5a20e4917d150cdbc5ec0c3a9a27 100644 (file)
@@ -669,7 +669,8 @@ DSAStackTy::DSAVarData DSAStackTy::getTopDSA(ValueDecl *D, bool FromParent) {
     if (auto *CTD = CTSD->getSpecializedTemplate())
       RD = CTD->getTemplatedDecl();
   if (IsConstant &&
-      !(SemaRef.getLangOpts().CPlusPlus && RD && RD->hasMutableFields())) {
+      !(SemaRef.getLangOpts().CPlusPlus && RD && RD->hasDefinition() &&
+        RD->hasMutableFields())) {
     // Variables with const-qualified type having no mutable member may be
     // listed in a firstprivate clause, even if they are static data members.
     DSAVarData DVarTemp = hasDSA(D, MatchesAnyClause(OMPC_firstprivate),
index 8aee8414f0340728b0ac26fbfc300ae4d2c1cad9..4db55a019549c063d47595f6ff84e34afb2d1b69 100644 (file)
@@ -5,7 +5,12 @@ void foo() {
 
 #pragma omp parallel // expected-error {{unexpected OpenMP directive '#pragma omp parallel'}}
 
+struct S;
+S& bar();
 int main(int argc, char **argv) {
+  S &s = bar();
+  #pragma omp parallel
+  (void)&s;
   #pragma omp parallel { // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}}
   foo();
   #pragma omp parallel ( // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}}