-
Notifications
You must be signed in to change notification settings - Fork 771
[temp.res.general] p5: dependent qualified-id and using-declarator #4791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
First of all, a qualified name as defined in [basic.lookup.qual.general] is very much different from a qualified-id, and intentionally so. Second, [temp.res.general] p5 expressly uses qualified-id and in the next sentence discusses using-declarator; applying an "if and only if" clarification to the second sentence in p5 fixes that issue without messing with qualified-id. @opensdh, any thoughts here? |
Consider this example struct Test{
typedef int type;
};
Test::type a = 0; //#1 Is the terminal name in |
I'm certainly not going to address any specification ambiguities of a qualified-id vs. a simple-type-specifier vs. a using-declarator etc. in an editorial issue. However, it seems plausible to add simple-type-specifier to the list in [basic.lookup.qual.general] p2. |
@jensmaurer Agree. I also think the first sentence in [temp.res#general-5] should also avoid using template<class T>
struct C{
T::type member_;
};
|
No, I think this is the operative paragraph where we differentiate between qualified-id and simple-type-specifier in a dependent context. I think it's too early to talk about either here, and we should simply talk about the grammatical form nested-name-specifier |
If we already know we have a simple-type-specifier (because that's the only possibility per the grammar), we don't need temp.res.general p5 to tell us we're dealing with a type. It's only in the case where the general grammar rules would allow parsing as a qualified-id that we need the type-only context rules. |
Violent agree! qualified-id can only appear as an expression, if we directly say it's a typename T::type * id;
In addition, I think the grammar nested-name-specifier :: identifier is not sufficient to list all possible components, such as |
No, |
That has enforced the subject of this issue. Since the component whose terminal name is in type-only context is one of them: typename-specifier, nested-name-specifier, elaborated-type-specifier, class-or-decltype, type-specifier, decl-specifier. How could these components be a qualified-id? |
T::type * id; We could say I cannot figure out a simple way that can avoid use qualified-id but can mention all the grammars whose forms look like the qualified-id. Could we say
To emphasize that it's not necessary to be a qualified-id eventually? |
I think we only need to discuss the two forms "nested-name-specifier identifier" and "nested-name-specifier template(opt) simple-type-id". Everything else is already unambiguous between simple-type-specifier and qualified-id. |
For the record, I don't have anything to add here beyond what we said in the CWG review, which was itself not a complete answer. |
In the current draft, [basic.lookup.qual#general-2] specifies the qualified name, where it seems that it intends to use
qualified-id
to cover such as a simple-type-specifier that has the form nested-name-specifieropttype-name. In other words, they all can form nested-name-specifier identifier on syntax. However, they are not the same thing on grammar.Furthermore, [temp.res#general-5] also intends to use qualified-id to cover a simple-type-specifier that may have the aforementioned form. The meaning of the qualified-id is vague in such use, consider a using-declarator, which has the form nested-name-specifier unqualified-id
using T::identifier;
Does that mean any rule that uses the qualified-id to cover the form that is not a qualified-id on grammar can also impose on the using-declarator that has the same form? It seems a defect in the current standard. This issue is also mentioned on SO.
This example would illustrate the vague
GCC agrees on this example while Clang reports an error. If we say the using-declarator at
#1
is considered as a qualified-id, then Clang is right due to [temp.res#general-5] imposes on it.I don't think it's a good example here, I still think Clang is wrong, even if
T::Type
is not considered to denote a type, I didn't see any big deal at#1
. This issue intends to expose that the extra given meaning toqualified-id
would make its meaning be a mess in some rules that mentionqualified-id
.The text was updated successfully, but these errors were encountered: