]> granicus.if.org Git - clang/commitdiff
[OPENMP]Initial fix PR42392: Improve -Wuninitialized warnings for OpenMP programs.
authorAlexey Bataev <a.bataev@hotmail.com>
Thu, 11 Jul 2019 14:54:17 +0000 (14:54 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Thu, 11 Jul 2019 14:54:17 +0000 (14:54 +0000)
Summary:
Some OpenMP clauses rely on the values of the variables. If the variable
is not initialized and used in OpenMP clauses that depend on the
variables values, it should be reported that the uninitialized variable
is used in the OpenMP clause expression.
This patch adds initial processing for uninitialized variables in OpenMP
constructs. Currently, it checks for use of the uninitialized variables
in the structured blocks.

Reviewers: NoQ, Szelethus, dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet

Subscribers: rnkovacs, guansong, jfb, jdoerfert, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D64356

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365786 91177308-0d34-0410-b5e6-96231b3b80d8

41 files changed:
include/clang/AST/OpenMPClause.h
include/clang/AST/StmtOpenMP.h
lib/AST/OpenMPClause.cpp
lib/Analysis/CFG.cpp
lib/Analysis/UninitializedValues.cpp
test/Analysis/cfg-openmp.cpp [new file with mode: 0644]
test/OpenMP/atomic_messages.c
test/OpenMP/critical_messages.cpp
test/OpenMP/distribute_parallel_for_messages.cpp
test/OpenMP/distribute_parallel_for_simd_misc_messages.c
test/OpenMP/distribute_simd_misc_messages.c
test/OpenMP/for_misc_messages.c
test/OpenMP/for_simd_misc_messages.c
test/OpenMP/master_messages.cpp
test/OpenMP/ordered_messages.cpp
test/OpenMP/parallel_for_messages.cpp
test/OpenMP/parallel_for_simd_messages.cpp
test/OpenMP/parallel_messages.cpp
test/OpenMP/parallel_sections_messages.cpp
test/OpenMP/sections_misc_messages.c
test/OpenMP/simd_misc_messages.c
test/OpenMP/single_misc_messages.c
test/OpenMP/target_depend_messages.cpp
test/OpenMP/target_parallel_for_messages.cpp
test/OpenMP/target_parallel_for_simd_messages.cpp
test/OpenMP/target_parallel_messages.cpp
test/OpenMP/target_simd_messages.cpp
test/OpenMP/target_teams_distribute_messages.cpp
test/OpenMP/target_teams_distribute_parallel_for_messages.cpp
test/OpenMP/target_teams_distribute_parallel_for_simd_messages.cpp
test/OpenMP/target_teams_distribute_simd_messages.cpp
test/OpenMP/target_teams_messages.cpp
test/OpenMP/target_update_messages.cpp
test/OpenMP/task_messages.cpp
test/OpenMP/taskgroup_messages.cpp
test/OpenMP/taskloop_misc_messages.c
test/OpenMP/taskloop_simd_misc_messages.c
test/OpenMP/teams_distribute_parallel_for_messages.cpp
test/OpenMP/teams_distribute_parallel_for_simd_messages.cpp
test/OpenMP/teams_distribute_simd_messages.cpp
test/OpenMP/teams_messages.cpp

index 7171b03960048328003be0f4ae03ad5221d1d498..c6daf73a623bd0b3c4785dd100e6a23dddd2425c 100644 (file)
@@ -90,6 +90,15 @@ public:
     return const_child_range(Children.begin(), Children.end());
   }
 
+  /// Get the iterator range for the expressions used in the clauses. Used
+  /// expressions include only the children that must be evaluated at the
+  /// runtime before entering the construct.
+  child_range used_children();
+  const_child_range used_children() const {
+    auto Children = const_cast<OMPClause *>(this)->children();
+    return const_child_range(Children.begin(), Children.end());
+  }
+
   static bool classof(const OMPClause *) { return true; }
 };
 
@@ -294,6 +303,13 @@ public:
     return const_child_range(&Allocator, &Allocator + 1);
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_allocator;
   }
@@ -384,6 +400,13 @@ public:
     return const_child_range(Children.begin(), Children.end());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_allocate;
   }
@@ -478,6 +501,13 @@ public:
     return const_child_range(&Condition, &Condition + 1);
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_if;
   }
@@ -533,6 +563,13 @@ public:
     return const_child_range(&Condition, &Condition + 1);
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_final;
   }
@@ -598,6 +635,13 @@ public:
     return const_child_range(&NumThreads, &NumThreads + 1);
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_num_threads;
   }
@@ -657,6 +701,13 @@ public:
     return const_child_range(&Safelen, &Safelen + 1);
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_safelen;
   }
@@ -715,6 +766,13 @@ public:
     return const_child_range(&Simdlen, &Simdlen + 1);
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_simdlen;
   }
@@ -774,6 +832,13 @@ public:
     return const_child_range(&NumForLoops, &NumForLoops + 1);
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_collapse;
   }
@@ -846,6 +911,13 @@ public:
     return const_child_range(const_child_iterator(), const_child_iterator());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_default;
   }
@@ -920,6 +992,13 @@ public:
     return const_child_range(const_child_iterator(), const_child_iterator());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_proc_bind;
   }
@@ -955,6 +1034,13 @@ public:
     return const_child_range(const_child_iterator(), const_child_iterator());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_unified_address;
   }
@@ -990,6 +1076,13 @@ public:
     return const_child_range(const_child_iterator(), const_child_iterator());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_unified_shared_memory;
   }
@@ -1025,6 +1118,13 @@ public:
     return const_child_range(const_child_iterator(), const_child_iterator());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_reverse_offload;
   }
@@ -1061,6 +1161,13 @@ public:
     return const_child_range(const_child_iterator(), const_child_iterator());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_dynamic_allocators;
   }
@@ -1144,6 +1251,13 @@ public:
     return const_child_range(const_child_iterator(), const_child_iterator());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_atomic_default_mem_order;
   }
@@ -1330,6 +1444,13 @@ public:
     return const_child_range(Children.begin(), Children.end());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_schedule;
   }
@@ -1419,6 +1540,13 @@ public:
     return const_child_range(&NumForLoops, &NumForLoops + 1);
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_ordered;
   }
@@ -1451,6 +1579,13 @@ public:
     return const_child_range(const_child_iterator(), const_child_iterator());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_nowait;
   }
@@ -1483,6 +1618,13 @@ public:
     return const_child_range(const_child_iterator(), const_child_iterator());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_untied;
   }
@@ -1516,6 +1658,13 @@ public:
     return const_child_range(const_child_iterator(), const_child_iterator());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_mergeable;
   }
@@ -1547,6 +1696,13 @@ public:
     return const_child_range(const_child_iterator(), const_child_iterator());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_read;
   }
@@ -1579,6 +1735,13 @@ public:
     return const_child_range(const_child_iterator(), const_child_iterator());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_write;
   }
@@ -1612,6 +1775,13 @@ public:
     return const_child_range(const_child_iterator(), const_child_iterator());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_update;
   }
@@ -1645,6 +1815,13 @@ public:
     return const_child_range(const_child_iterator(), const_child_iterator());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_capture;
   }
@@ -1678,6 +1855,13 @@ public:
     return const_child_range(const_child_iterator(), const_child_iterator());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_seq_cst;
   }
@@ -1776,6 +1960,13 @@ public:
     return const_child_range(Children.begin(), Children.end());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_private;
   }
@@ -1908,6 +2099,13 @@ public:
     return const_child_range(Children.begin(), Children.end());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_firstprivate;
   }
@@ -2112,6 +2310,13 @@ public:
     return const_child_range(Children.begin(), Children.end());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_lastprivate;
   }
@@ -2177,6 +2382,13 @@ public:
     return const_child_range(Children.begin(), Children.end());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_shared;
   }
@@ -2404,6 +2616,13 @@ public:
     return const_child_range(Children.begin(), Children.end());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_reduction;
   }
@@ -2629,6 +2848,13 @@ public:
     return const_child_range(Children.begin(), Children.end());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_task_reduction;
   }
@@ -2877,6 +3103,13 @@ public:
     return const_child_range(Children.begin(), Children.end());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_in_reduction;
   }
@@ -3121,6 +3354,13 @@ public:
     return const_child_range(Children.begin(), Children.end());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_linear;
   }
@@ -3213,6 +3453,13 @@ public:
     return const_child_range(Children.begin(), Children.end());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_aligned;
   }
@@ -3382,6 +3629,13 @@ public:
     return const_child_range(Children.begin(), Children.end());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_copyin;
   }
@@ -3538,6 +3792,13 @@ public:
     return const_child_range(Children.begin(), Children.end());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_copyprivate;
   }
@@ -3608,6 +3869,13 @@ public:
     return const_child_range(Children.begin(), Children.end());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_flush;
   }
@@ -3732,6 +4000,13 @@ public:
     return const_child_range(Children.begin(), Children.end());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_depend;
   }
@@ -3799,6 +4074,13 @@ public:
     return const_child_range(&Device, &Device + 1);
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_device;
   }
@@ -3831,6 +4113,13 @@ public:
     return const_child_range(const_child_iterator(), const_child_iterator());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_threads;
   }
@@ -3862,6 +4151,13 @@ public:
     return const_child_range(const_child_iterator(), const_child_iterator());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_simd;
   }
@@ -4699,6 +4995,13 @@ public:
     return const_child_range(Children.begin(), Children.end());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_map;
   }
@@ -4767,6 +5070,13 @@ public:
     return const_child_range(&NumTeams, &NumTeams + 1);
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_num_teams;
   }
@@ -4836,6 +5146,13 @@ public:
     return const_child_range(&ThreadLimit, &ThreadLimit + 1);
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_thread_limit;
   }
@@ -4897,6 +5214,13 @@ public:
     return const_child_range(&Priority, &Priority + 1);
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_priority;
   }
@@ -4952,6 +5276,13 @@ public:
     return const_child_range(&Grainsize, &Grainsize + 1);
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_grainsize;
   }
@@ -4984,6 +5315,13 @@ public:
     return const_child_range(const_child_iterator(), const_child_iterator());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_nogroup;
   }
@@ -5039,6 +5377,13 @@ public:
     return const_child_range(&NumTasks, &NumTasks + 1);
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_num_tasks;
   }
@@ -5093,6 +5438,13 @@ public:
     return const_child_range(&Hint, &Hint + 1);
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_hint;
   }
@@ -5205,6 +5557,13 @@ public:
     return const_child_range(Children.begin(), Children.end());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_dist_schedule;
   }
@@ -5310,6 +5669,13 @@ public:
     return const_child_range(const_child_iterator(), const_child_iterator());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_defaultmap;
   }
@@ -5420,6 +5786,13 @@ public:
     return const_child_range(Children.begin(), Children.end());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_to;
   }
@@ -5531,6 +5904,13 @@ public:
     return const_child_range(Children.begin(), Children.end());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_from;
   }
@@ -5687,6 +6067,13 @@ public:
     return const_child_range(Children.begin(), Children.end());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_use_device_ptr;
   }
@@ -5783,6 +6170,13 @@ public:
     return const_child_range(Children.begin(), Children.end());
   }
 
+  child_range used_children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_is_device_ptr;
   }
index e56d094a4a0eebba75773a6d95272bfbf25d37a2..e37f5b1e00048c22e0801ec1613dde6d9b1c7468 100644 (file)
@@ -87,6 +87,63 @@ protected:
   }
 
 public:
+  /// Iterates over expressions/statements used in the construct.
+  class used_clauses_child_iterator
+      : public llvm::iterator_adaptor_base<
+            used_clauses_child_iterator, ArrayRef<OMPClause *>::iterator,
+            std::forward_iterator_tag, Stmt *, ptrdiff_t, Stmt *, Stmt *> {
+    ArrayRef<OMPClause *>::iterator End;
+    OMPClause::child_iterator ChildI, ChildEnd;
+
+    void MoveToNext() {
+      if (ChildI != ChildEnd)
+        return;
+      while (this->I != End) {
+        ++this->I;
+        if (this->I != End) {
+          ChildI = (*this->I)->used_children().begin();
+          ChildEnd = (*this->I)->used_children().end();
+          if (ChildI != ChildEnd)
+            return;
+        }
+      }
+    }
+
+  public:
+    explicit used_clauses_child_iterator(ArrayRef<OMPClause *> Clauses)
+        : used_clauses_child_iterator::iterator_adaptor_base(Clauses.begin()),
+          End(Clauses.end()) {
+      if (this->I != End) {
+        ChildI = (*this->I)->used_children().begin();
+        ChildEnd = (*this->I)->used_children().end();
+        MoveToNext();
+      }
+    }
+    Stmt *operator*() const { return *ChildI; }
+    Stmt *operator->() const { return **this; }
+
+    used_clauses_child_iterator &operator++() {
+      ++ChildI;
+      if (ChildI != ChildEnd)
+        return *this;
+      if (this->I != End) {
+        ++this->I;
+        if (this->I != End) {
+          ChildI = (*this->I)->used_children().begin();
+          ChildEnd = (*this->I)->used_children().end();
+        }
+      }
+      MoveToNext();
+      return *this;
+    }
+  };
+
+  static llvm::iterator_range<used_clauses_child_iterator>
+  used_clauses_children(ArrayRef<OMPClause *> Clauses) {
+    return {used_clauses_child_iterator(Clauses),
+            used_clauses_child_iterator(llvm::makeArrayRef(Clauses.end(), 0))};
+  }
+
   /// Iterates over a filtered subrange of clauses applied to a
   /// directive.
   ///
index 5bd4ad81bf84ffe05d23a601165c2880826d9e38..41520b380276c615d97b2b1b93acc3946360910d 100644 (file)
@@ -35,6 +35,20 @@ OMPClause::child_range OMPClause::children() {
   llvm_unreachable("unknown OMPClause");
 }
 
+OMPClause::child_range OMPClause::used_children() {
+  switch (getClauseKind()) {
+#define OPENMP_CLAUSE(Name, Class)                                             \
+  case OMPC_##Name:                                                            \
+    return static_cast<Class *>(this)->used_children();
+#include "clang/Basic/OpenMPKinds.def"
+  case OMPC_threadprivate:
+  case OMPC_uniform:
+  case OMPC_unknown:
+    break;
+  }
+  llvm_unreachable("unknown OMPClause");
+}
+
 OMPClauseWithPreInit *OMPClauseWithPreInit::get(OMPClause *C) {
   auto *Res = OMPClauseWithPreInit::get(const_cast<const OMPClause *>(C));
   return Res ? const_cast<OMPClauseWithPreInit *>(Res) : nullptr;
index 80f5a46ceab4745dc4153dbcde8ccc80c93a6e1b..f92d311111e7b61e2d85661a7f2cf6ae6f7574a7 100644 (file)
@@ -589,6 +589,8 @@ private:
   CFGBlock *VisitStmt(Stmt *S, AddStmtChoice asc);
   CFGBlock *VisitChildren(Stmt *S);
   CFGBlock *VisitNoRecurse(Expr *E, AddStmtChoice asc);
+  CFGBlock *VisitOMPExecutableDirective(OMPExecutableDirective *D,
+                                        AddStmtChoice asc);
 
   void maybeAddScopeBeginForVarDecl(CFGBlock *B, const VarDecl *VD,
                                     const Stmt *S) {
@@ -2058,6 +2060,10 @@ CFGBlock *CFGBuilder::Visit(Stmt * S, AddStmtChoice asc) {
   if (Expr *E = dyn_cast<Expr>(S))
     S = E->IgnoreParens();
 
+  if (Context->getLangOpts().OpenMP)
+    if (auto *D = dyn_cast<OMPExecutableDirective>(S))
+      return VisitOMPExecutableDirective(D, asc);
+
   switch (S->getStmtClass()) {
     default:
       return VisitStmt(S, asc);
@@ -4728,6 +4734,36 @@ CFGBlock *CFGBuilder::VisitConditionalOperatorForTemporaryDtors(
   return Block;
 }
 
+CFGBlock *CFGBuilder::VisitOMPExecutableDirective(OMPExecutableDirective *D,
+                                                  AddStmtChoice asc) {
+  if (asc.alwaysAdd(*this, D)) {
+    autoCreateBlock();
+    appendStmt(Block, D);
+  }
+
+  // Iterate over all used expression in clauses.
+  CFGBlock *B = Block;
+
+  // Reverse the elements to process them in natural order. Iterators are not
+  // bidirectional, so we need to create temp vector.
+  for (Stmt *S : llvm::reverse(llvm::to_vector<8>(
+           OMPExecutableDirective::used_clauses_children(D->clauses())))) {
+    assert(S && "Expected non-null used-in-clause child.");
+    if (CFGBlock *R = Visit(S))
+      B = R;
+  }
+  // Visit associated structured block if any.
+  if (!D->isStandaloneDirective())
+    if (Stmt *S = D->getStructuredBlock()) {
+      if (!isa<CompoundStmt>(S))
+        addLocalScopeAndDtors(S);
+      if (CFGBlock *R = addStmt(S))
+        B = R;
+    }
+
+  return B;
+}
+
 /// createBlock - Constructs and adds a new CFGBlock to the CFG.  The block has
 ///  no successors or predecessors.  If this is the first block created in the
 ///  CFG, it is automatically set to be the Entry and Exit of the CFG.
index cea401ab5c3f72f5ded17398d873b8905c37551b..8a233d4a44f105aea266432494c9d98e97adbfd2 100644 (file)
@@ -350,6 +350,7 @@ public:
   void VisitBinaryOperator(BinaryOperator *BO);
   void VisitCallExpr(CallExpr *CE);
   void VisitCastExpr(CastExpr *CE);
+  void VisitOMPExecutableDirective(OMPExecutableDirective *ED);
 
   void operator()(Stmt *S) { Visit(S); }
 
@@ -455,6 +456,11 @@ void ClassifyRefs::VisitUnaryOperator(UnaryOperator *UO) {
     classify(UO->getSubExpr(), Use);
 }
 
+void ClassifyRefs::VisitOMPExecutableDirective(OMPExecutableDirective *ED) {
+  for (Stmt *S : OMPExecutableDirective::used_clauses_children(ED->clauses()))
+    classify(cast<Expr>(S), Use);
+}
+
 static bool isPointerToConst(const QualType &QT) {
   return QT->isAnyPointerType() && QT->getPointeeType().isConstQualified();
 }
@@ -532,6 +538,7 @@ public:
   void VisitDeclStmt(DeclStmt *ds);
   void VisitObjCForCollectionStmt(ObjCForCollectionStmt *FS);
   void VisitObjCMessageExpr(ObjCMessageExpr *ME);
+  void VisitOMPExecutableDirective(OMPExecutableDirective *ED);
 
   bool isTrackedVar(const VarDecl *vd) {
     return ::isTrackedVar(vd, cast<DeclContext>(ac.getDecl()));
@@ -707,6 +714,16 @@ void TransferFunctions::VisitObjCForCollectionStmt(ObjCForCollectionStmt *FS) {
   }
 }
 
+void TransferFunctions::VisitOMPExecutableDirective(
+    OMPExecutableDirective *ED) {
+  for (Stmt *S : OMPExecutableDirective::used_clauses_children(ED->clauses())) {
+    assert(S && "Expected non-null used-in-clause child.");
+    Visit(S);
+  }
+  if (!ED->isStandaloneDirective())
+    Visit(ED->getStructuredBlock());
+}
+
 void TransferFunctions::VisitBlockExpr(BlockExpr *be) {
   const BlockDecl *bd = be->getBlockDecl();
   for (const auto &I : bd->captures()) {
diff --git a/test/Analysis/cfg-openmp.cpp b/test/Analysis/cfg-openmp.cpp
new file mode 100644 (file)
index 0000000..2f734d1
--- /dev/null
@@ -0,0 +1,340 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG %s 2>&1 -fopenmp | FileCheck %s
+
+// CHECK-LABEL:  void xxx(int argc)
+void xxx(int argc) {
+// CHECK:        [B1]
+// CHECK-NEXT:   1: int x;
+  int x;
+// CHECK-NEXT:   2: x
+// CHECK-NEXT:   3: [B1.2] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:   4: argc
+// CHECK-NEXT:   5: [B1.4] = [B1.3]
+// CHECK-NEXT:   6: #pragma omp atomic read
+// CHECK-NEXT:    [B1.5];
+#pragma omp atomic read
+  argc = x;
+// CHECK-NEXT:   7: x
+// CHECK-NEXT:   8: [B1.7] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:   9: argc
+// CHECK-NEXT:  10: [B1.9] = [B1.8]
+// CHECK-NEXT:  11: #pragma omp critical
+// CHECK-NEXT:    [B1.10];
+#pragma omp critical
+  argc = x;
+// CHECK-NEXT:  12: x
+// CHECK-NEXT:  13: [B1.12] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:  14: argc
+// CHECK-NEXT:  15: [B1.14] = [B1.13]
+// CHECK-NEXT:  16: #pragma omp distribute parallel for
+// CHECK-NEXT:    for (int i = 0; i < 10; ++i)
+// CHECK-NEXT:        [B1.15];
+#pragma omp distribute parallel for
+  for (int i = 0; i < 10; ++i)
+    argc = x;
+// CHECK-NEXT:  17: x
+// CHECK-NEXT:  18: [B1.17] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:  19: argc
+// CHECK-NEXT:  20: [B1.19] = [B1.18]
+// CHECK-NEXT:  21: #pragma omp distribute parallel for simd
+// CHECK-NEXT:    for (int i = 0; i < 10; ++i)
+// CHECK-NEXT:        [B1.20];
+#pragma omp distribute parallel for simd
+  for (int i = 0; i < 10; ++i)
+    argc = x;
+// CHECK-NEXT:  22: x
+// CHECK-NEXT:  23: [B1.22] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:  24: argc
+// CHECK-NEXT:  25: [B1.24] = [B1.23]
+// CHECK-NEXT:  26: #pragma omp distribute simd
+// CHECK-NEXT:    for (int i = 0; i < 10; ++i)
+// CHECK-NEXT:        [B1.25];
+#pragma omp distribute simd
+  for (int i = 0; i < 10; ++i)
+    argc = x;
+// CHECK-NEXT:  27: x
+// CHECK-NEXT:  28: [B1.27] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:  29: argc
+// CHECK-NEXT:  30: [B1.29] = [B1.28]
+// CHECK-NEXT:  31: #pragma omp for
+// CHECK-NEXT:    for (int i = 0; i < 10; ++i)
+// CHECK-NEXT:        [B1.30];
+#pragma omp for
+  for (int i = 0; i < 10; ++i)
+    argc = x;
+// CHECK-NEXT:  32: x
+// CHECK-NEXT:  33: [B1.32] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:  34: argc
+// CHECK-NEXT:  35: [B1.34] = [B1.33]
+// CHECK-NEXT:  36: #pragma omp for simd
+// CHECK-NEXT:    for (int i = 0; i < 10; ++i)
+// CHECK-NEXT:        [B1.35];
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i)
+    argc = x;
+// CHECK-NEXT:  37: x
+// CHECK-NEXT:  38: [B1.37] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:  39: argc
+// CHECK-NEXT:  40: [B1.39] = [B1.38]
+// CHECK-NEXT:  41: #pragma omp master
+// CHECK-NEXT:    [B1.40];
+#pragma omp master
+  argc = x;
+// CHECK-NEXT:  42: x
+// CHECK-NEXT:  43: [B1.42] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:  44: argc
+// CHECK-NEXT:  45: [B1.44] = [B1.43]
+// CHECK-NEXT:  46: #pragma omp ordered
+// CHECK-NEXT:    [B1.45];
+// CHECK-NEXT:  47: #pragma omp for ordered
+// CHECK-NEXT:    for (int i = 0; i < 10; ++i) {
+// CHECK-NEXT:[B1.46]    }
+#pragma omp for ordered
+  for (int i = 0; i < 10; ++i) {
+#pragma omp ordered
+    argc = x;
+  }
+// CHECK-NEXT:  48: x
+// CHECK-NEXT:  49: [B1.48] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:  50: argc
+// CHECK-NEXT:  51: [B1.50] = [B1.49]
+// CHECK-NEXT:  52: #pragma omp parallel for
+// CHECK-NEXT:    for (int i = 0; i < 10; ++i)
+// CHECK-NEXT:        [B1.51];
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i)
+    argc = x;
+// CHECK-NEXT:  53: x
+// CHECK-NEXT:  54: [B1.53] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:  55: argc
+// CHECK-NEXT:  56: [B1.55] = [B1.54]
+// CHECK-NEXT:  57: #pragma omp parallel for simd
+// CHECK-NEXT:    for (int i = 0; i < 10; ++i)
+// CHECK-NEXT:        [B1.56];
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i)
+    argc = x;
+// CHECK-NEXT:  58: x
+// CHECK-NEXT:  59: [B1.58] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:  60: argc
+// CHECK-NEXT:  61: [B1.60] = [B1.59]
+// CHECK-NEXT:  62: #pragma omp parallel
+// CHECK-NEXT:    [B1.61];
+#pragma omp parallel
+  argc = x;
+// CHECK-NEXT:  63: x
+// CHECK-NEXT:  64: [B1.63] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:  65: argc
+// CHECK-NEXT:  66: [B1.65] = [B1.64]
+// CHECK-NEXT:  67: #pragma omp parallel sections
+// CHECK-NEXT:    {
+// CHECK-NEXT:        [B1.66];
+// CHECK-NEXT:    }
+#pragma omp parallel sections
+  {
+    argc = x;
+  }
+// CHECK-NEXT:  68: x
+// CHECK-NEXT:  69: [B1.68] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:  70: argc
+// CHECK-NEXT:  71: [B1.70] = [B1.69]
+// CHECK-NEXT:  72: #pragma omp simd
+// CHECK-NEXT:    for (int i = 0; i < 10; ++i)
+// CHECK-NEXT:        [B1.71];
+#pragma omp simd
+  for (int i = 0; i < 10; ++i)
+    argc = x;
+// CHECK-NEXT:  73: x
+// CHECK-NEXT:  74: [B1.73] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:  75: argc
+// CHECK-NEXT:  76: [B1.75] = [B1.74]
+// CHECK-NEXT:  77: #pragma omp single
+// CHECK-NEXT:    [B1.76];
+#pragma omp single
+  argc = x;
+// CHECK-NEXT:  78: x
+// CHECK-NEXT:  79: [B1.78] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:  80: argc
+// CHECK-NEXT:  81: [B1.80] = [B1.79]
+// CHECK-NEXT:  82: #pragma omp target depend(in : argc)
+// CHECK-NEXT:    [B1.81];
+#pragma omp target depend(in \
+                          : argc)
+  argc = x;
+// CHECK-NEXT:  83: x
+// CHECK-NEXT:  84: [B1.83] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:  85: argc
+// CHECK-NEXT:  86: [B1.85] = [B1.84]
+// CHECK-NEXT:  87: #pragma omp target parallel for
+// CHECK-NEXT:    for (int i = 0; i < 10; ++i)
+// CHECK-NEXT:        [B1.86];
+#pragma omp target parallel for
+  for (int i = 0; i < 10; ++i)
+    argc = x;
+// CHECK-NEXT:  88: x
+// CHECK-NEXT:  89: [B1.88] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:  90: argc
+// CHECK-NEXT:  91: [B1.90] = [B1.89]
+// CHECK-NEXT:  92: #pragma omp target parallel for simd
+// CHECK-NEXT:    for (int i = 0; i < 10; ++i)
+// CHECK-NEXT:        [B1.91];
+#pragma omp target parallel for simd
+  for (int i = 0; i < 10; ++i)
+    argc = x;
+// CHECK-NEXT:  93: x
+// CHECK-NEXT:  94: [B1.93] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:  95: argc
+// CHECK-NEXT:  96: [B1.95] = [B1.94]
+// CHECK-NEXT:  97: #pragma omp target parallel
+// CHECK-NEXT:    [B1.96];
+#pragma omp target parallel
+  argc = x;
+// CHECK-NEXT:  98: x
+// CHECK-NEXT:  99: [B1.98] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT: 100: argc
+// CHECK-NEXT: 101: [B1.100] = [B1.99]
+// CHECK-NEXT: 102: #pragma omp target simd
+// CHECK-NEXT:    for (int i = 0; i < 10; ++i)
+// CHECK-NEXT:        [B1.101];
+#pragma omp target simd
+  for (int i = 0; i < 10; ++i)
+    argc = x;
+// CHECK-NEXT: 103: x
+// CHECK-NEXT: 104: [B1.103] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT: 105: argc
+// CHECK-NEXT: 106: [B1.105] = [B1.104]
+// CHECK-NEXT: 107: #pragma omp target teams distribute
+// CHECK-NEXT:    for (int i = 0; i < 10; ++i)
+// CHECK-NEXT:        [B1.106];
+#pragma omp target teams distribute
+  for (int i = 0; i < 10; ++i)
+    argc = x;
+// CHECK-NEXT: 108: x
+// CHECK-NEXT: 109: [B1.108] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT: 110: argc
+// CHECK-NEXT: 111: [B1.110] = [B1.109]
+// CHECK-NEXT: 112: #pragma omp target teams distribute parallel for
+// CHECK-NEXT:    for (int i = 0; i < 10; ++i)
+// CHECK-NEXT:        [B1.111];
+#pragma omp target teams distribute parallel for
+  for (int i = 0; i < 10; ++i)
+    argc = x;
+// CHECK-NEXT: 113: x
+// CHECK-NEXT: 114: [B1.113] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT: 115: argc
+// CHECK-NEXT: 116: [B1.115] = [B1.114]
+// CHECK-NEXT: 117: #pragma omp target teams distribute parallel for simd
+// CHECK-NEXT:    for (int i = 0; i < 10; ++i)
+// CHECK-NEXT:        [B1.116];
+#pragma omp target teams distribute parallel for simd
+  for (int i = 0; i < 10; ++i)
+    argc = x;
+// CHECK-NEXT: 118: x
+// CHECK-NEXT: 119: [B1.118] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT: 120: argc
+// CHECK-NEXT: 121: [B1.120] = [B1.119]
+// CHECK-NEXT: 122: #pragma omp target teams distribute simd
+// CHECK-NEXT:    for (int i = 0; i < 10; ++i)
+// CHECK-NEXT:        [B1.121];
+#pragma omp target teams distribute simd
+  for (int i = 0; i < 10; ++i)
+    argc = x;
+// CHECK-NEXT: 123: x
+// CHECK-NEXT: 124: [B1.123] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT: 125: argc
+// CHECK-NEXT: 126: [B1.125] = [B1.124]
+// CHECK-NEXT: 127: #pragma omp target teams
+// CHECK-NEXT:    [B1.126];
+#pragma omp target teams
+  argc = x;
+// CHECK-NEXT: 128: #pragma omp target update to(x)
+#pragma omp target update to(x)
+// CHECK-NEXT: 129: x
+// CHECK-NEXT: 130: [B1.129] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT: 131: argc
+// CHECK-NEXT: 132: [B1.131] = [B1.130]
+  argc = x;
+// CHECK-NEXT: 133: x
+// CHECK-NEXT: 134: [B1.133] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT: 135: argc
+// CHECK-NEXT: 136: [B1.135] = [B1.134]
+// CHECK-NEXT: 137: #pragma omp task
+// CHECK-NEXT:    [B1.136];
+#pragma omp task
+  argc = x;
+// CHECK-NEXT: 138: x
+// CHECK-NEXT: 139: [B1.138] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT: 140: argc
+// CHECK-NEXT: 141: [B1.140] = [B1.139]
+// CHECK-NEXT: 142: #pragma omp taskgroup
+// CHECK-NEXT:    [B1.141];
+#pragma omp taskgroup
+  argc = x;
+// CHECK-NEXT: 143: x
+// CHECK-NEXT: 144: [B1.143] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT: 145: argc
+// CHECK-NEXT: 146: [B1.145] = [B1.144]
+// CHECK-NEXT: 147: #pragma omp taskloop
+// CHECK-NEXT:    for (int i = 0; i < 10; ++i)
+// CHECK-NEXT:        [B1.146];
+#pragma omp taskloop
+  for (int i = 0; i < 10; ++i)
+    argc = x;
+// CHECK-NEXT: 148: x
+// CHECK-NEXT: 149: [B1.148] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT: 150: argc
+// CHECK-NEXT: 151: [B1.150] = [B1.149]
+// CHECK-NEXT: 152: #pragma omp taskloop simd
+// CHECK-NEXT:    for (int i = 0; i < 10; ++i)
+// CHECK-NEXT:        [B1.151];
+#pragma omp taskloop simd
+  for (int i = 0; i < 10; ++i)
+    argc = x;
+// CHECK-NEXT: 153: x
+// CHECK-NEXT: 154: [B1.153] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT: 155: argc
+// CHECK-NEXT: 156: [B1.155] = [B1.154]
+// CHECK-NEXT: 157: #pragma omp teams distribute parallel for
+// CHECK-NEXT:    for (int i = 0; i < 10; ++i)
+// CHECK-NEXT:        [B1.156];
+// CHECK-NEXT: 158: #pragma omp target
+#pragma omp target
+#pragma omp teams distribute parallel for
+  for (int i = 0; i < 10; ++i)
+    argc = x;
+// CHECK-NEXT:[B1.157] 159: x
+// CHECK-NEXT: 160: [B1.159] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT: 161: argc
+// CHECK-NEXT: 162: [B1.161] = [B1.160]
+// CHECK-NEXT: 163: #pragma omp teams distribute parallel for simd
+// CHECK-NEXT:    for (int i = 0; i < 10; ++i)
+// CHECK-NEXT:        [B1.162];
+// CHECK-NEXT: 164: #pragma omp target
+#pragma omp target
+#pragma omp teams distribute parallel for simd
+  for (int i = 0; i < 10; ++i)
+    argc = x;
+// CHECK-NEXT:[B1.163] 165: x
+// CHECK-NEXT: 166: [B1.165] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT: 167: argc
+// CHECK-NEXT: 168: [B1.167] = [B1.166]
+// CHECK-NEXT: 169: #pragma omp teams distribute simd
+// CHECK-NEXT:    for (int i = 0; i < 10; ++i)
+// CHECK-NEXT:        [B1.168];
+// CHECK-NEXT: 170: #pragma omp target
+#pragma omp target
+#pragma omp teams distribute simd
+  for (int i = 0; i < 10; ++i)
+    argc = x;
+// CHECK-NEXT:[B1.169] 171: x
+// CHECK-NEXT: 172: [B1.171] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT: 173: argc
+// CHECK-NEXT: 174: [B1.173] = [B1.172]
+// CHECK-NEXT: 175: #pragma omp teams
+// CHECK-NEXT:    [B1.174];
+// CHECK-NEXT: 176: #pragma omp target
+#pragma omp target
+#pragma omp teams
+  argc = x;
+// CHECK-NEXT:[B1.175]   Preds
+}
+
index bace18aba9e4c33bbf51b0ad78bba273ddd67281..abc703d578d2c0d4ecac81552623af582d3bdfae 100644 (file)
@@ -2,6 +2,12 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp atomic read
+  argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 int foo() {
 L1:
   foo();
index 1eec70e283337a3ce00287ce0b80812fbffe18a0..54349e3396379a71ca42ddfe56ed8ac468c179af 100644 (file)
@@ -4,6 +4,12 @@
 
 int foo();
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp critical
+  argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 template<typename T, int N>
 int tmain(int argc, char **argv) { // expected-note {{declared here}}
   #pragma omp critical
index 248d09b8cc6f679f5900fda86806e0d06c7bd833..b2e6e4c64df9c7871aa1b4cbcf41411ea16debf0 100644 (file)
@@ -5,6 +5,13 @@
 void foo() {
 }
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp distribute parallel for
+  for (int i = 0; i < 10; ++i)
+    argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 #pragma omp distribute parallel for // expected-error {{unexpected OpenMP directive '#pragma omp distribute parallel for'}}
 
 int main(int argc, char **argv) {
index e4cefcbf72111f94cc6efb8a1c2df3654b5402c5..1721da876dc53d8a9ba4df129af137cd45b64319 100644 (file)
@@ -2,6 +2,13 @@
 
 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -verify %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp distribute parallel for simd
+  for (int i = 0; i < 10; ++i)
+    argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp distribute parallel for simd'}}
 #pragma omp distribute parallel for simd
 
index 5286e5f8d6ddd0e90160702901888300b916a0f4..37dcf8ba7b051c228ea069d69ab449b97bf65ccb 100644 (file)
@@ -2,6 +2,13 @@
 
 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -verify %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp distribute simd
+  for (int i = 0; i < 10; ++i)
+    argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp distribute simd'}}
 #pragma omp distribute simd
 
index e36a1c6db012b3bb8f0e19e95c5c0f9ac013903d..324c70bee318da6c008b904a731a190331b6a98f 100644 (file)
@@ -2,6 +2,13 @@
 
 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -triple x86_64-unknown-unknown -verify %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp for
+  for (int i = 0; i < 10; ++i)
+    argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp for'}}
 #pragma omp for
 
index bdce97431c0ab001aedf218303d49b462cb6fd58..f7c864d135e56bf8e1fca6c89671c30b82e7c688 100644 (file)
@@ -2,6 +2,13 @@
 
 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -verify %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i)
+    argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp for simd'}}
 #pragma omp for simd
 
index 07c863f909935fdce4d2a493e9d7065d3bb41479..ce403f0cb050954c50f3c2dd8790c588619bd5ef 100644 (file)
@@ -2,6 +2,12 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp master
+  argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 int foo();
 
 int main() {
index 6404ec8bf914af6e5fee914e22df79df61f9aab6..3fb69dbb60a9491910eb911f00c5c52ed38c6ad6 100644 (file)
@@ -6,6 +6,15 @@
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -std=c++98 -o - %s -Wuninitialized
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp for ordered
+  for (int i = 0; i < 10; ++i) {
+#pragma omp ordered
+    argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+  }
+}
+
 int foo();
 
 template <class T>
index b53f6fa3196f97f1d7fef8b262f27a31577117b4..d131b47d98355bcbd65cb0b8ef0e8ac91fd840c2 100644 (file)
@@ -2,6 +2,13 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp parallel for
+  for(int i = 0; i < 10; ++i)
+  argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 void foo() {
 }
 
index e0e77841319342383c3a8e64c341703aa6789bbf..8237406a1c068aba157db06fd0a2e50a2533099e 100644 (file)
@@ -2,6 +2,13 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 -o - %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i)
+    argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 void foo() {
 }
 
index 6012487562e3f6759ba1be26f5f8f29a19c3072c..ac8869fff9d2e06a099830670674ca4da805104d 100644 (file)
@@ -5,6 +5,12 @@
 void foo() {
 }
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp parallel
+  argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 #pragma omp parallel // expected-error {{unexpected OpenMP directive '#pragma omp parallel'}}
 
 int a;
index ab4c34a6b2c3566feacc810234fe2c8a3d226449..06182802d7a986418d742b4d7c82facc2883d59b 100644 (file)
@@ -2,6 +2,14 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp parallel sections
+{
+  argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+}
+
 void foo() {
 }
 
index 8d8dab86a3c394593d8c47f237df7b8d1b94a916..fd775400b428b2b2da4e6e9d064346535fe44bd8 100644 (file)
@@ -2,6 +2,14 @@
 
 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -verify %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp sections
+{
+  argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+}
+
 void foo();
 
 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp sections'}}
index 1fbb6fa263cc5838b86a7ff16525421409e13eb0..88df2535103c80e8a896bd3a2f371467393bb7ed 100644 (file)
@@ -2,6 +2,13 @@
 
 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -verify %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp simd
+  for (int i = 0; i < 10; ++i)
+    argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp simd'}}
 #pragma omp simd
 
index 0d4ab5a77b5a3c1f1152652be004b90d6658293e..96f40c69f50e86d0220882643b6b9378e426e732 100644 (file)
@@ -2,6 +2,12 @@
 
 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -verify %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp single
+  argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 void foo();
 
 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp single'}}
index a7ac1760e6b50ddab06dbea04f9ad2795da0a2a3..a18bc5d5edcb123ed14501d8fdcef1966b786d33 100644 (file)
@@ -2,6 +2,12 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp target depend(in : argc)
+  argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 void foo() {
 }
 
index e78154a5b3dae06ce8bc8967fca1727754de207c..8fa8ed6ad88bc47ac874dbd9d22591a5925dc804 100644 (file)
@@ -2,6 +2,13 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp target parallel for
+  for (int i = 0; i < 10; ++i)
+    argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 void foo() {
 }
 
index 5d07c895b9eb5b87e86239c874f2871aed5bf1fc..ff98e2cbdd3efdb877125f2c1f7e96adde6e8445 100644 (file)
@@ -2,6 +2,13 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp target parallel for simd
+  for (int i = 0; i < 10; ++i)
+    argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 void foo() {
 }
 
index f664ec121094cc0941578f830808cafb174a2b10..25e63bb72b5915f43a3c56145b0890c692c91e84 100644 (file)
@@ -1,9 +1,15 @@
 // RUN: %clang_cc1 -verify -fopenmp -std=c++11 -o - %s -Wuninitialized
 // RUN: not %clang_cc1 -fopenmp -std=c++11 -fopenmp-targets=aaa-bbb-ccc-ddd -o - %s 2>&1 | FileCheck %s
 
-// RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 -o - %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 -o - %s -Wuninitialized
 // CHECK: error: OpenMP target is invalid: 'aaa-bbb-ccc-ddd'
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp target parallel
+  argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 void foo() {
 }
 
index 37f5fae9502bc7c463d348c14c8016fe3d9b8703..ea53482517acda19873400a91ed10b227cffb0b5 100644 (file)
@@ -2,6 +2,13 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp target simd
+  for (int i = 0; i < 10; ++i)
+    argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 void foo() {
 }
 
index a685acf7f3e6f6ccd6c2c652f6d2e6b2f9c108f3..7b6b36ec82610d4af486b7b61169c70c2e2b0458 100644 (file)
@@ -2,6 +2,13 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp target teams distribute
+  for (int i = 0; i < 10; ++i)
+    argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 void foo() {
 }
 
index a9a7ca1617d27880611b9c80ecc0d4a4a703d340..b70f87a39b44fca13b80ca0e3037a5d0d5ed2eab 100644 (file)
@@ -2,6 +2,13 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp target teams distribute parallel for
+  for (int i = 0; i < 10; ++i)
+    argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 void foo() {
 }
 
index f6050925d644a2dcd0ee8a354f6c1bc735f6000a..3de30c3f6386ba98bba2d2c4085b21093b77396e 100644 (file)
@@ -2,6 +2,13 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp target teams distribute parallel for simd
+  for (int i = 0; i < 10; ++i)
+    argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 void foo() {
 }
 
index 77e85f1c137660e7ccfdd1c18e134ce2154f63c5..cd3d38a2d48aa2fcf9395f6044bbb98193b31b5d 100644 (file)
@@ -2,6 +2,13 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp target teams distribute simd
+  for (int i = 0; i < 10; ++i)
+    argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 void foo() {
 }
 
index 406b9841f506dbc7f2b6b0434e6d1cef67eaa529..c690d9de82c3ed025915a224b4f823f55c9c0bce 100644 (file)
@@ -2,6 +2,12 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 -o - %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp target teams
+  argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 void foo() {
 }
 
index 0adb87584e1d2275f05c933735e706330da85dfc..581fdd8e0a9bd64e16d975381b5e5b524150d5e7 100644 (file)
@@ -2,6 +2,12 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp target update to(x)
+  argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 void foo() {
 }
 
index e52b2fae5c7ed79b289bf0e36e0ff508997df282..062125f5f6ea6e0cabfc0c255d1aa055ef9d6126 100644 (file)
@@ -2,6 +2,12 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp task
+  argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 void foo() {
 }
 
index f7503ff3c14b0e0bb808cd6afb82b1a83f225dca..6bac1614b6a977a488124cc8e62f76dbad01e857 100644 (file)
@@ -2,6 +2,12 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp taskgroup
+  argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 int foo();
 
 int main() {
index 6ab4696fc73b1274cd0eb1f61257fa453a5fe738..795419416204196150d7a81b16a448a87da1e087 100644 (file)
@@ -2,6 +2,13 @@
 
 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -triple x86_64-unknown-unknown -verify %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp taskloop
+  for (int i = 0; i < 10; ++i)
+    argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp taskloop'}}
 #pragma omp taskloop
 
index 2b6bbe9f378c4f6269e5fe54807d98edf53162a3..1f2087f2d89eda50d524e13579192d61c8c027bb 100644 (file)
@@ -2,6 +2,13 @@
 
 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -triple x86_64-unknown-unknown -verify %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp taskloop simd
+  for (int i = 0; i < 10; ++i)
+    argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp taskloop simd'}}
 #pragma omp taskloop simd
 
index 906c330428669cac8776a55bb7e5a9fa33a823fd..ff4fa0767b83b7ce57f39dd6d4b748a097c52201 100644 (file)
@@ -2,6 +2,14 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp target
+#pragma omp teams distribute parallel for
+  for (int i = 0; i < 10; ++i)
+    argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 void foo() {
 }
 
index c07cef186103e3f2b303648cf5987befd4e2c024..e01b3f118b32322299558a62cb494ed7b10b6172 100644 (file)
@@ -2,6 +2,14 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp target
+#pragma omp teams distribute parallel for simd
+  for (int i = 0; i < 10; ++i)
+    argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 void foo() {
 }
 
index faaf16a23da86bd9db90b1244bdfb787bada9fc6..3ec2c874a4732a19ff221090e10be4b6f45dfe0a 100644 (file)
@@ -2,6 +2,14 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp target
+#pragma omp teams distribute simd
+  for (int i = 0; i < 10; ++i)
+    argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 void foo() {
 }
 
index b01c428118ca897a761364d7809c6bd986a49917..8196140be76e44f1cf854568f538f6f9dcbe54a0 100644 (file)
@@ -2,6 +2,13 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 -o - %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp target
+#pragma omp teams
+  argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 void foo() {
 }