8ba442bc21
Combined with 'da98651 - Revert "DR2064: decltype(E) is only a dependent', this change (5a391d3
) caused verifier errors when building Chromium. See https://crbug.com/1168494#c1 for a reproducer. Additionally it reverts changes that were dependent on this one, see below. > Following up on PR48517, fix handling of template arguments that refer > to dependent declarations. > > Treat an id-expression that names a local variable in a templated > function as being instantiation-dependent. > > This addresses a language defect whereby a reference to a dependent > declaration can be formed without any construct being value-dependent. > Fixing that through value-dependence turns out to be problematic, so > instead this patch takes the approach (proposed on the core reflector) > of allowing the use of pointers or references to (but not values of) > dependent declarations inside value-dependent expressions, and instead > treating template arguments as dependent if they evaluate to a constant > involving such dependent declarations. > > This ends up affecting a bunch of OpenMP tests, due to OpenMP > imprecisely handling instantiation-dependent constructs, bailing out > early instead of processing dependent constructs to the extent possible > when handling the template. > > Previously committed as8c1f2d15b8
, and > reverted because a dependency commit was reverted. This reverts commit5a391d38ac
. It also restores clang/test/SemaCXX/coroutines.cpp to its state beforeda986511fb
. Revert "[c++20] P1907R1: Support for generalized non-type template arguments of scalar type." > Previously committed as9e08e51a20
, and > reverted because a dependency commit was reverted. This incorporates the > following follow-on commits that were also reverted: > >7e84aa1b81
by Simon Pilgrim >ed13d8c667
by me >95c7b6cadb
by Sam McCall >430d5d8429
by Dave Zarzycki This reverts commit4b574008ae
. Revert "[msabi] Mangle a template argument referring to array-to-pointer decay" > [msabi] Mangle a template argument referring to array-to-pointer decay > applied to an array the same as the array itself. > > This follows MS ABI, and corrects a regression from the implementation > of generalized non-type template parameters, where we "forgot" how to > mangle this case. This reverts commit18e093faf7
.
108 lines
5.1 KiB
C++
108 lines
5.1 KiB
C++
// RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
|
|
|
|
// RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
|
|
|
|
void foo() {
|
|
}
|
|
|
|
bool foobool(int argc) {
|
|
return argc;
|
|
}
|
|
|
|
struct S1; // expected-note {{declared here}} expected-note {{declared here}}
|
|
|
|
template <class T, int N>
|
|
T tmain(T argc) {
|
|
T b = argc, c, d, e, f, g;
|
|
char ** argv;
|
|
static T a;
|
|
T z;
|
|
|
|
#pragma omp target
|
|
#pragma omp teams distribute simd dist_schedule // expected-error {{expected '(' after 'dist_schedule'}}
|
|
for (int i = 0; i < 10; ++i) foo();
|
|
|
|
#pragma omp target
|
|
#pragma omp teams distribute simd dist_schedule ( // expected-error {{expected 'static' in OpenMP clause 'dist_schedule'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
|
|
for (int i = 0; i < 10; ++i) foo();
|
|
|
|
#pragma omp target
|
|
#pragma omp teams distribute simd dist_schedule () // expected-error {{expected 'static' in OpenMP clause 'dist_schedule'}}
|
|
for (int i = 0; i < 10; ++i) foo();
|
|
|
|
#pragma omp target
|
|
#pragma omp teams distribute simd dist_schedule (static // expected-error {{expected ')'}} expected-note {{to match this '('}}
|
|
for (int i = 0; i < 10; ++i) foo();
|
|
|
|
#pragma omp target
|
|
#pragma omp teams distribute simd dist_schedule (static, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
|
|
for (int i = 0; i < 10; ++i) foo();
|
|
|
|
#pragma omp target
|
|
#pragma omp teams distribute simd dist_schedule (argc)) // expected-error {{expected 'static' in OpenMP clause 'dist_schedule'}} expected-warning {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}}
|
|
for (int i = 0; i < 10; ++i) foo();
|
|
|
|
#pragma omp target
|
|
#pragma omp teams distribute simd dist_schedule (static, argc > 0 ? argv[1] : argv[2]) // expected-error2 {{expression must have integral or unscoped enumeration type, not 'char *'}}
|
|
for (int i = 0; i < 10; ++i) foo();
|
|
|
|
#pragma omp target
|
|
#pragma omp teams distribute simd dist_schedule (static), dist_schedule (static, z) // expected-error {{directive '#pragma omp teams distribute simd' cannot contain more than one 'dist_schedule' clause}}
|
|
for (int i = 0; i < 10; ++i) foo();
|
|
|
|
#pragma omp target
|
|
#pragma omp teams distribute simd dist_schedule (static, S1) // expected-error {{'S1' does not refer to a value}}
|
|
for (int i = 0; i < 10; ++i) foo();
|
|
|
|
#pragma omp target
|
|
#pragma omp teams distribute simd dist_schedule (static, argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error3 {{expression must have integral or unscoped enumeration type, not 'char *'}}
|
|
for (int i = 0; i < 10; ++i) foo();
|
|
|
|
return T();
|
|
}
|
|
|
|
int main(int argc, char **argv) {
|
|
int z;
|
|
#pragma omp target
|
|
#pragma omp teams distribute simd dist_schedule // expected-error {{expected '(' after 'dist_schedule'}}
|
|
for (int i = 0; i < 10; ++i) foo();
|
|
|
|
#pragma omp target
|
|
#pragma omp teams distribute simd dist_schedule ( // expected-error {{expected 'static' in OpenMP clause 'dist_schedule'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
|
|
for (int i = 0; i < 10; ++i) foo();
|
|
|
|
#pragma omp target
|
|
#pragma omp teams distribute simd dist_schedule () // expected-error {{expected 'static' in OpenMP clause 'dist_schedule'}}
|
|
for (int i = 0; i < 10; ++i) foo();
|
|
|
|
#pragma omp target
|
|
#pragma omp teams distribute simd dist_schedule (static // expected-error {{expected ')'}} expected-note {{to match this '('}}
|
|
for (int i = 0; i < 10; ++i) foo();
|
|
|
|
#pragma omp target
|
|
#pragma omp teams distribute simd dist_schedule (static, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
|
|
for (int i = 0; i < 10; ++i) foo();
|
|
|
|
#pragma omp target
|
|
#pragma omp teams distribute simd dist_schedule (argc)) // expected-error {{expected 'static' in OpenMP clause 'dist_schedule'}} expected-warning {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}}
|
|
for (int i = 0; i < 10; ++i) foo();
|
|
|
|
#pragma omp target
|
|
#pragma omp teams distribute simd dist_schedule (static, argc > 0 ? argv[1] : argv[2]) // expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}}
|
|
for (int i = 0; i < 10; ++i) foo();
|
|
|
|
#pragma omp target
|
|
#pragma omp teams distribute simd dist_schedule (static), dist_schedule (static, 1 + z) // expected-error {{directive '#pragma omp teams distribute simd' cannot contain more than one 'dist_schedule' clause}}
|
|
for (int i = 0; i < 10; ++i) foo();
|
|
|
|
#pragma omp target
|
|
#pragma omp teams distribute simd dist_schedule (static, S1) // expected-error {{'S1' does not refer to a value}}
|
|
for (int i = 0; i < 10; ++i) foo();
|
|
|
|
#pragma omp target
|
|
#pragma omp teams distribute simd dist_schedule (static, argv[1]=2) // expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
|
|
for (int i = 0; i < 10; ++i) foo();
|
|
|
|
return (tmain<int, 5>(argc) + tmain<char, 1>(argv[0][0])); // expected-note {{in instantiation of function template specialization 'tmain<int, 5>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<char, 1>' requested here}}
|
|
}
|