
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 as 8c1f2d15b826591cdf6bd6b468b8a7d23377b29e, and > reverted because a dependency commit was reverted. This reverts commit 5a391d38ac6c561ba908334d427f26124ed9132e. It also restores clang/test/SemaCXX/coroutines.cpp to its state before da986511fb9da1a46a0ca4dba2e49e2426036303. Revert "[c++20] P1907R1: Support for generalized non-type template arguments of scalar type." > Previously committed as 9e08e51a20d0d2b1c5724bb17e969d036fced4cd, and > reverted because a dependency commit was reverted. This incorporates the > following follow-on commits that were also reverted: > > 7e84aa1b81e72d44bcc58ffe1731bfc7abb73ce0 by Simon Pilgrim > ed13d8c66781b50ff007cb089c5905f9bb9e8af2 by me > 95c7b6cadbc9a3d4376ef44edbeb3c8bb5b8d7fc by Sam McCall > 430d5d8429473c2b10b109991d7577a3cea41140 by Dave Zarzycki This reverts commit 4b574008aef5a7235c1f894ab065fe300d26e786. 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 commit 18e093faf726d15f210ab4917142beec51848258.
96 lines
6.4 KiB
C++
96 lines
6.4 KiB
C++
// RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
|
|
// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s -Wuninitialized
|
|
|
|
// RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
|
|
// RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wuninitialized
|
|
|
|
// expected-note@* 0+{{declared here}}
|
|
|
|
void foo() {
|
|
}
|
|
|
|
bool foobool(int argc) {
|
|
return argc;
|
|
}
|
|
|
|
struct S1;
|
|
|
|
template <class T, typename S, int N, int ST>
|
|
T tmain(T argc, S **argv) {
|
|
int j;
|
|
#pragma omp target simd collapse // expected-error {{expected '(' after 'collapse'}}
|
|
for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
|
|
#pragma omp target simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
|
|
for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
|
|
#pragma omp target simd collapse () // expected-error {{expected expression}}
|
|
for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
|
|
// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
|
|
// expected-error@+1 2 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
|
|
#pragma omp target simd collapse (argc
|
|
for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
|
|
// expected-error@+1 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
|
|
#pragma omp target simd collapse (ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
|
|
for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
|
|
#pragma omp target simd collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}}
|
|
for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
|
|
#pragma omp target simd collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}}
|
|
for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 for loops after '#pragma omp target simd', but found only 1}}
|
|
|
|
// expected-error@+3 2 {{directive '#pragma omp target simd' cannot contain more than one 'collapse' clause}}
|
|
// expected-error@+2 {{argument to 'collapse' clause must be a strictly positive integer value}}
|
|
// expected-error@+1 2 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
|
|
#pragma omp target simd collapse (foobool(argc)), collapse (true), collapse (-5)
|
|
for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
|
|
#pragma omp target simd collapse (S) // expected-error {{'S' does not refer to a value}}
|
|
for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
|
|
|
|
// expected-error@+1 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
|
|
#pragma omp target simd collapse (j=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
|
|
for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
|
|
#pragma omp target simd collapse (1)
|
|
for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
|
|
#pragma omp target simd collapse (N) // expected-error {{argument to 'collapse' clause must be a strictly positive integer value}}
|
|
for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
|
|
#pragma omp target simd collapse (2) // expected-note {{as specified in 'collapse' clause}}
|
|
foo(); // expected-error {{expected 2 for loops after '#pragma omp target simd'}}
|
|
return argc;
|
|
}
|
|
|
|
int main(int argc, char **argv) {
|
|
int j;
|
|
#pragma omp target simd collapse // expected-error {{expected '(' after 'collapse'}}
|
|
for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
|
|
#pragma omp target simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
|
|
for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
|
|
#pragma omp target simd collapse () // expected-error {{expected expression}}
|
|
for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
|
|
#pragma omp target simd collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}}
|
|
for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp target simd', but found only 1}}
|
|
#pragma omp target simd collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}} expected-note {{as specified in 'collapse' clause}}
|
|
for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp target simd', but found only 1}}
|
|
|
|
#pragma omp target simd collapse (foobool(1) > 0 ? 1 : 2) // expected-error {{integral constant expression}} expected-note 0+{{constant expression}}
|
|
for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
|
|
|
|
// expected-error@+3 {{integral constant expression}} expected-note@+3 0+{{constant expression}}
|
|
// expected-error@+2 2 {{directive '#pragma omp target simd' cannot contain more than one 'collapse' clause}}
|
|
// expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
|
|
#pragma omp target simd collapse (foobool(argc)), collapse (true), collapse (-5)
|
|
for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
|
|
#pragma omp target simd collapse (S1) // expected-error {{'S1' does not refer to a value}}
|
|
for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
|
|
|
|
// expected-error@+1 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
|
|
#pragma omp target simd collapse (j=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
|
|
for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
|
|
// expected-error@+3 {{statement after '#pragma omp target simd' must be a for loop}}
|
|
// expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
|
|
#pragma omp target simd collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
|
|
foo();
|
|
#pragma omp target simd collapse (2) // expected-note {{as specified in 'collapse' clause}}
|
|
foo(); // expected-error {{expected 2 for loops after '#pragma omp target simd'}}
|
|
// expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
|
|
return tmain<int, char, 1, 0>(argc, argv);
|
|
}
|
|
|